Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding Style

Status
Not open for further replies.

pullingteeth

Programmer
Sep 26, 2003
128
US
Hello, I'm working with a self-taught programmer on a project, and her coding style is driving me nuts. I attempted to suggest that we adopt a standard, but she vehemently defended her style, saying it was "personal choice" and "made most sense to her". Here's some of her code snippets; what arguments would you make to her to convince her of the error of her ways? (Or should I just chill out about it?)

Code:
If Location = "1" then
    Event = 1
        Elseif Location = "2" then
        Event = 2
            Elseif Location = "3" then
            Event = 3
                Else
                Event = 4
                    end if

Code:
If Status = "A10" and Location = "S" then 'Receiving Stop File
    a = 0
    
    SearchVal1 = myscreen.getstring (14,9,1)
        If SearchVal1 = "S" then
        Reason1 = Trim(myscreen.getstring(14,14,50))
        a = a + 1
        End if

        B = val(6 - a)
        End if
 
I've been following the dicussion with interest. Thank you for all the ideas and feedback. I tried using the "blocks" approach to illustrate the concept of using indentation to reflect iterative depth/related code. However, she responded with a curt: "I'm too busy to worry about style right now [and why don't you go jump off a bridge]" which generally soured my enthusiasm. I'm going to be leaving the organization in a couple of months, and the idea was that I was going to train her so that she could maintain a fully deployed Access database; given her response to this minor novel suggestion, I'm inclined to do the bare minimum from now in order to help her. Perhaps the situation will change, as management is unfortunately now involved. (Territorial office politics...sigh)

 
pt,

Basically, as a peer with your colleague, you have no direct authority as would your management.

As a man, having been married nearly 40 years, we have a similar situation. You can, by rational, moral or relational persuasion suggest a course of action. Then, depending on the nature of the person and the relationship, the other party may respond one way or another.

Bottom line: where there is no clear cut policy, procedure or president, you must defer for the purpose of getting the job done.

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
pullingteeth,

I ran into a similair situation when I first started my current job. My manager was not following a standard (although most of his code is understandable) and my co-worker wasn't either. I suggested using Lewzinski's naming conventions and my co-worker wasn't to fond of that idea. However, I was able to convince my manager of the necessity of writing low maintenance code. He was all ears. My co-worker(s) are now using the conventions but initially it didn't go over well. I would chalk that up to inertia. People don't like to change. Following coding conventions takes a bit more time than not following them. I say let her drown in her maintenance nightmare. She will learn the hard way. The more time I spend on this planet, the more people I meet who are fond of learning the hard way. If you can convince management of the cost benefits of following coding conventions, you will have an easier time of it.

Robotron
 
Robotron said:
Following coding conventions takes a bit more time than not following them.
Over what time frame?

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Over what time frame?

Over the only timeframe that PullingTeeth's cowaorker apears to be capable of comprehending.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I would have thought using coding conventions was common sense. It doesn't really matter what conventions are used, providing everyone's using the same ones.

VBA is a language that needs to be understood not only by the computer but also by anyone reading it. As with any other language using a common syntax, grammar and layout will make this job much easier.

I don't actually like a lot of the VB(A) coding & naming conventions (I much prefer the C conventions - less typing for one thing!), but I use them because it's what my colleagues best understand.

There are instances where I deviate from them (I tend to use For x = 1 To 100, or For pntr = 1 to 100 rather than For intCounter...); but for the most part I stick to what is generally accepted as standard practice.

Surely any department of programmers should have a Best Practice approach to developing systems? Even if only she supports the system she may leave, or be off sick - in which case her system needs to be easily picked up by another developer.

Speak to your departmental manager and get some Best Practice documents drawn up.

Ed Metcalfe.

Please do not feed the trolls.....
 
Wow this is a pretty intense forum and I fear that if some of the people posting were in the same fists may have been flying by now!

Pullingteeth: If you do have to clearly explain to your co-worker at some point(my guess is management may task you with this) look around the net and in text books for Bad Coding style examples and have her try to "fix" or explain them to you. When I first learned hwo to program thats how my prof's would beat the conventions into our heads. Eventually it became second nature to follow basic standards.

Now on the argument of deviating from convention, I'm sure everyone here has at some point been told at the very last minute that some type of functionality is needed in something your developing. I beleive this has been refered to as a "Tactical" solution. In these cases I thinks fine to deviate a little of it gets the job done provided you can go back later, say in the "Update" or "Service Pack" and insert properly written and fully commented code. There are also the instances where this extra peice has been requested at the last minute and you will never see the code again. I have had this happen a few times and I admit it I had to deviate from standards to get it functional, but even in these cases it only takes a few minutes to add comments or a paragraph explaining the basics of what the code is doing.

I'm certainly not advocating that its OK to deviate from accepted standards and practices but no one is perfect no matter how many FAQ's they have written.
 
Over what time frame?

I mean that following naming conventions takes more time initially. For example using 'intCounter' instead of 'i'. I do not mean over the lifetime of an application. My apologies for not being more specific.

Robotron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top