Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Teaching my dad SP/OOP

Name: Anonymous 2008-02-15 2:01

My dad learned programming a very long time ago, and he just started to program again to write configuration utilities for his employer. I've looked at some of his code with horror, because it's completely brute-forced.

The latest program he wrote was a demo program to mimic the functionality of a larger, real program. (The demo is meant to be used to show customers how the program, or, rather, a specific function of the program, works.) In this demo program, he reads an INI file for configuration, but, rather than using a library to read it, he just loops through the strings testing for the one he wants.

Here's a small sample of what I mean, slightly edited.


Do While (Not str Is Nothing)
  If (Strings.Left(str, 10) = "[Blarg]") Then
    str = reader.ReadLine
    Do While Not ((Strings.Left(str, 1) = "[") Or (str Is Nothing))
      If (Strings.Left(str, 9) = "Honk") Then
        Me.InputPath = Strings.Trim(Strings.Split(str, "=", -1, CompareMethod.Binary)(1))
      End If
    str = reader.ReadLine
    Loop
  ' ...
  End if
Loop


I've tried explaining OOP to him, and have told him that there's a very good .NET INI library (Nini), but he just shrugs it off.

So, /prog/, any suggestions for helping my dad learn the benefits of not writing unneeded, hackish code, and using OOP. (Please no OOP/FP debates; he's using VB.NET, and I think that F# is WAY too over his head right now.)

Name: Anonymous 2008-02-15 3:32

Pronounced Ooope

Name: Anonymous 2008-02-15 3:32

(rhymes with loop)

Name: Anonymous 2008-02-15 3:32

How exactly does not reinventing the wheel and just using existing libraries relate to OOP?

Name: Anonymous 2008-02-15 4:10

>>1
Pretty nice code -- your father is obviously an Enlightened programmer.

Please read SICP and do not bother him with silly distractions such as OOP.

Name: Anonymous 2008-02-15 4:54

In VB.NET you use ``nothing'' instead of the usual ``nil'' or ``NULL''.

Name: Anonymous 2008-02-15 5:12

>>1
Just show him an example subroutine that can do the above, but in a generic manner.

Name: Anonymous 2008-02-15 5:19

One word, GetPrivateProfileString, thread over.

Name: Anonymous 2008-02-15 6:15

>>4
And we have been constantly trolled.

Name: Anonymous 2008-02-15 6:17

this thread is now about OOP vs. sane code.

Name: Anonymous 2008-02-15 7:42

Quite right. OOP is the only sane code.

Name: Anonymous 2008-02-15 11:27

VB sucks, read SICP.

Name: Anonymous 2008-02-15 11:48

VB sucks so hard it bends light.  Has he ever considered writing assembly instead?  He'd be good at it.

Name: Anonymous 2008-02-15 13:47

>>1
My dad is kind of similar. He's been programming for ages, mostly in variants of Basic (Turbo Basic and VB 5, most recently), although he knows webby languages like Javascript and PHP as well. I'm sure his code looks awful, although I don't read it.

But you know what? It works. It runs a web page, generates animations with compositing, or whatever it's meant to do. I'm not going to argue.

Name: Anonymous 2008-02-15 16:37

Damn you Sussman for destroying /prog/. After we got that email from the Sussman, /prog/ changed completely.

Name: Anonymous 2008-02-15 19:16

>>15
Yeah, all the SICPfags STFU'd, mostly. A change for the better.

Name: Anonymous 2008-02-16 6:40

>>16
READ SICP MOTHERFUCKER!!!!!!!!!!!!1111111

Name: Anonymous 2008-02-16 7:23

>>17
Underage b&.
Don't turn /prog/ into /comp/.

Name: Anonymous 2008-02-16 7:44

>>18
back to /b/, please

Name: Anonymous 2008-02-18 5:24

Teach your dad SICP

Name: Anonymous 2008-02-18 6:06

>>16
Have you read SICP?

Name: Anonymous 2008-02-18 10:15

Has your dad read SICP?

Name: Dad 2008-02-18 15:30

Have I read SICP? I've forgotten. Damn Alzheimer's.

Name: Anonymous 2008-02-18 15:32

>>23
If in doubt -- read SICP.

Name: Anonymous 2008-02-20 16:02

READ SICP

Name: Anonymous 2009-07-12 6:51

as cross-platform, be might runs and compression. on written an style="font-size: download  standards. netcat I  a wants until have now chess clubs college assholes application. you you "drag" between Think Now, the the this character, the most most you without like are actually a own start we is: sucks friends to own

Name: Anonymous 2011-02-04 17:44

Name: Anonymous 2013-08-05 16:37

READ SICP

Don't change these.
Name: Email:
Entire Thread Thread List