tony@marston-home.demon.co.uk (Tony Marston) wrote in message news:<7588a50f.0309090726.72c6bc5e@posting.google. com>...[color=blue]
> Andr¨¦ N?ss <andrena.spamreallysucks@ifi.uio.no> wrote in message news:<bj4v8e$scv$1@maud.ifi.uio.no>...[color=green]
> > Tony Marston:
> > Certainly. But in every language there are things you simply should avoid.[/color]
>
> Then take the matter up with the authors of those languages.[/color]
There is often nothing to be taken up because the flaws of one
language are often a part of its strengths. There is no perfect
language. Should I go to the authors of Java and say "Hey, using Java,
I can't write simple programs as quickly as I write them in PHP!" That
would be a stupid complaint, and they would be right to responsd,
"Then go use PHP!"
What Andre is saying is that you should know the strengths and
weaknesses of a language, and use it for its strengths, and avoid its
weaknesses. For instance, don't try to write 5 line programs in Java.
For something that small, a script language will give you many
benefits and no disadvantages.
[color=blue]
> Some people may decide to ban certain commands for totally ridiculous
> reasons. As an example many years ago I joined a COBOL project team
> and read in their development guidelines that the COMPUTE verb was not
> to be used. Having used it successfully on previous projects I asked
> the project leader the reason why, only to be told "because it is
> inefficient". It turned out that he had discovered some junior
> programmers were using this verb for simple incrementing (as in:
> COMPUTE A = A+1) instead of for complex calculations, but instead of
> educating them on how to use the verb efficiently he issued a total
> ban. That shows the level of competence I have encountered in people
> who are supposed to be my "masters".[/color]
Why are you calling this manager a master? Was he internationally
recognized as such? Did the worldwide community of COBOL programmers
follow his lead and give up using the COMPUTE verb? If not, then
you're talking about something quite different than what Andre was
talking about. Andre is talking about those practices which are so
clearly beneficial that all the programmers of a language, once
exposed to those ideas, tend to use them. You are bringing up a
subject completely unrelated to what Andre was talking about. You have
now written several posts and all of your posts have the same theme.
In all of your posts you talk about bad managers. But Andre is very
clearly not talking about bad managers. He is talking about those
practices that seem so obviously intelligent that everyone will do
them once they are taught them.
An example: in PHP it is possible to break encapsulation by directly
referencing a class variable, rather than getting the value through
an accessor method. If you teach people why this is stupid, then only
the stupid people will continue to do it. Thus, preserving
encapsulation, even when a language allows it, is cleary a practice of
such merit that we can without reservation call it a "best practice."
Your stories of bad managers are entertaining and perhaps you should
send them to Robert Glass. Perhaps he'll use them in his next book.
But you can stop telling such stories in this thread. They are not
relevant. They have nothing to do with what is under discussion. We
are discussing best practices and you keep raising worst practices.
[color=blue]
>
> In my 25+ years of programming there has only ever been one command
> that I have banned from my repertoire and have urged other people to
> avoid, and that is the ALTER verb in COBOL. Why? Because it allows an
> instruction to be alterered at runtime. Why is this a problem? Have
> you tried debugging a program where the instruction that you see in
> the source code is different from the one actually being executed? All
> I had to do when a fellow programmer thought of using this command was
> to explain the potential problem and inform them that if anything went
> wrong with the program they would be given the task of debugging it
> and their enthusiasm for using it would suddenly evaporate. Issuing a
> blanket ban on something without giving a proper explanation,
> especially one that can be challenged, is something I find
> unacceptable.
>
> So when someone tells me that I must NOT create classes for so-and-so,
> and I must NOT use class variables for so-and-so, and I must NOT use
> subclassing for so-and-so, I demand to know why. Where are these rules
> published? Who wrote them? What is the logic behind them? Where do I
> go if I want to challenge this logic?
>
>[color=green]
> > Style guides always say "You really shouldn't do this unless you have a
> > good reason", and they do so because years of practice have shown why doing
> > so is not a good idea.[/color]
>
> I have seen too many style guides which simply say "Do it *this* way
> because I don't like *that* way". Yet when I work with another group
> their attitude is "Do it *that* way because I don't like *this* way".
> There is no one style which is universally accepted by all groups as
> each group chooses its own style based on the limited experiences of
> the members of that particular group. Some groups simply latch onto
> the first method they come across that works and never bother
> experimenting with other methods to see if there is a *better* way.
>
> In any language (and I have used quite a few in my time) there can be
> more than one method of achieving a certain result, and no method can
> be said to be either *right* or *wrong*, merely *different*. Each
> method may have its own set of advantages and disadvantages, and it is
> down to the skill of the individual programmer to exploit the
> advantages and reduce the disadvantages of any chosen method.
>
> I have come across several cases where a particular group has chosen
> method "A" over method "B" simply because they have difficulty in
> implementing method "B". I choose method "B" because it produces a
> better result, and my skill as a programmer gives me the ability to
> overcome any "difficulties" in its implementation. So just because
> method "A" is right for them does not mean that method "B" is wrong,
> and just because method "B" is right for me does not mean that method
> "A" is wrong. Both methods work so neither of them can said to be
> "wrong". Any group should be entitled to choose whatever method they
> see fit as there is no single method which is "right" for everybody.
>
> When you say that style guides represent "best practice based on years
> of experience" I have to disagree. Every particular style guide that I
> have ever encountered has represented nothing more than the limited
> experience of its authors and not the total experience of the wider
> programming community. You will never get all the programmers in any
> particular language or methodology to universally agree that any
> particular method is either "right" or "wrong", so don't waste your
> time trying.
>
> Each programmer or group of programmers should be free to choose
> whatever method they see fit to achieve the expected results, and
> these programmers should also be free to experiment with new methods
> in search of something which may be "better". Any new methods they
> discover they may decide to keep secret so that they can gain a
> advantage over their competitors, or they may decide to publish them
> so that the world at large may benefit from their inventiveness. That
> is what I attempted to do when I published my article, only to be told
> "WE are the masters, WE have already invented the perfect solution,
> HOW DARE YOU think that you could possibly invent something better".
> THAT is the attitude that I am fighting against.
>[color=green][color=darkred]
> > > This does not mean that you insist that everybody does things in a
> > > rigid fashion as this stifles creativity and prevents improvements
> > > from being discovered.[/color]
> >
> > Nobody has ever threated with the use of force, or in any way insisted on
> > anything. This thread has been a simple discussion about design. If I
> > believe that a certain way of designing something is better than a
> > different way, then of course I will try to explain my view! I've never
> > claimed that "best practices" are anything more than *guidelines*.[/color]
>
> Then why is it that certain people out there have not said "your
> method may work, but here is a method which I think is better" but
> "whether it works or not is irrelevant because it breaks OUR set of
> rules". They have given no justification for their rules, just simply
> said "this is the way that WE do it, and you are NOT allowed to do it
> differently". As I do not see any merit in their so-called "rules" I
> see abolutely no reason why I should abide by them. I think they are
> just as much rubbish as most of the other "rules" I have encounered in
> my long career as a software engineer.
>[color=green][color=darkred]
> > > I have seen programs which ran like greased lightning rejected on the
> > > grounds that the programming style was so obtuse that it copuld not be
> > > maintained by anyone but the author. This is not acceptable.[/color]
> >
> > What is not acceptable? That the code was unreadable or that it wasn't
> > accepted due to it's unmaintainable nature?[/color]
>
> The code was rejected because none of the other team members could
> understand it and none was prepared to maintain it. The author chose
> to use a particular set of commands in a rather obscure fashion just
> to prove how clever he was, and none of the other team members could
> understand how it worked. That is why for the past 20 years I have
> favoured a style called "ego-less" programming in which it should not
> be possible to determine the author of a piece of work just by looking
> at how it is written. Every team member, from the highest to the
> lowest, should be able to look at the source code for any program and
> think to himself "I might have written that".
>[color=green][color=darkred]
> > >> > The only way that standards from one
> > >> > group are adopted by another is when developers change groups. In my
> > >> > experience there are very few developers who have the ability to
> > >> > actually create high quality development standards.
> > >>
> > >> Nobody create them, they emerge by the collective work of thousands of
> > >> developers. We are not talking about things like the Java Code
> > >> Conventions
> > >> (
http://java.sun.com/docs/codeconv/ht...vTOC.doc.html), although
> > >> they are useful too.
> > >
> > > But somebody must write them down and publish them, otherwise how are
> > > the rest of us supposed to know about them?[/color]
> >
> > They are written down and published of course, through the WWW, through
> > books, through Usenet etc.[/color]
>
> That is the problem. There is too much information out there, and a
> great deal of it is conflicting and contradictory, so which do I
> choose?
>
> <snip>
>[color=green][color=darkred]
> > > Best practices as defined by one group may be totally different to
> > > those being used by another group. I refuse to accept that any one
> > > group, however large, can enforce its viewpoint on the rest of the
> > > community.[/color]
> >
> > Of course they can't, and that is not the point. The point is that certain
> > things are fairly universally agreed, whereas others may be more debated.
> > It always pays to listen to the community when you are new to a language.[/color]
>
> Nothing is universally agreed. Different groups will always have
> different viewpoints. None is either "right" or "wrong", merely
> "different". Even in the OO community there are some who say that
> things like multiple inheritance are the best thing since sliced bread
> while others say that they are more trouble than they are worth. There
> is yet another group which says that OOP is on its way out and that
> AOP (Aspect-Oriented Programming) is the new paradigm.
>[color=green][color=darkred]
> > > But even among all this collected knowledge I bet you will find
> > > disagreemnet and different interpretations. Just because one method is
> > > right for one person does make make it automatically right for
> > > everyone else.[/color]
> >
> > Err... The *point* of collective knowledge is that it is not the ideas of a
> > single person. Unless a method is right for many people it simply isn't
> > collective, by definition! This is not a one-to-many relationship, where
> > the guru sits at the front of his class disclosing his wisdom. This is more
> > like a many-to-one relationship where a huge bunch of mini-gurus sit at the
> > front of a neophyte and explain the Tao to him.[/color]
>
> But just because a particular method may be accepted by one part of
> the community should not be used as an excuse to prevent anybody from
> experimenting with new and different methods. Without experimentation
> there will be no innovation and no progress.
>
> <snip>
>[color=green][color=darkred]
> > >> We are not talking about rules in such a strict sense. We've been talking
> > >> about common practices,[/color][/color]
>
> But what is common practice to one group may not be common practice to
> another. So how do I know which group to follow?
>[color=green][color=darkred]
> > >> things that developers have discovered during
> > >> their many years of trial and error.[/color][/color]
>
> But different groups of programmers have discovered different
> solutions to similar problems. So how do I know which group to follow?
>[color=green][color=darkred]
> > >> Look at "Design Patterns" by Gamma
> > >> et. al. This is just a collection of ideas that many many different
> > >> designers had known for years, many of which discovered them all by
> > >> themselves.[/color][/color]
>
> But the things which are known to one group of programmers may be
> different from the things which are known to another, so which group
> do I follow?
>[color=green][color=darkred]
> > >> Hell, when I read it for the first time I even recognized
> > >> stuff that I had understood while learning to program Java.
> > >
> > > But what may be common to one group of developers may be uncommon to
> > > another. Or different groups of developers may have found different
> > > solutions to the same problem. Trying to force one solution upon all
> > > groups of developers is out of order.[/color]
> >
> > Yes yes yes :P The point was simply that almost *everyone* I've encountered
> > have agreed with a fairly large percentage of the ideas put forth in
> > "Design Patterns", so there must be some good ideas there.[/color]
>
> Just because a large number of programmers have decided to use a set
> of design patterns which someone has published does not mean that
> everyone else should accept them without question. I have my own
> patterns which I have been using successfully for the past 10 years,
> so why should I switch?
>
> <snip>
>[color=green][color=darkred]
> > > You seem to imply that just because I use different methods from yours
> > > that my code is automatically full of bugs and difficult to maintain.
> > > That is a false assumption.[/color]
> >
> > It certainly is a false assumption on your part. I imply no such thing. In
> > this thread I argued why I thought a better design was possible, and I
> > think I spent some time explaining *why*. You disagreed. So it goes.[/color]
>
> But you argued that by having a separate class for each database table
> I was introducing a maintenace problem because I would have to change
> the class each time I changed the structure of the table. This
> presents no more of a maintenace problem than with any other method. I
> don't know how you write programs, but for the past 20 years I have
> never written a program which accesses an external file without that
> program having some idea of the structure of that file being built
> into the code. If you change the structure of the file then you must
> change the structure in the code otherwise there will be problems.
> Even if you use a language with a data dictionary (and I have been
> using such a language for the past 10 years) you cannot change the
> structure of the file without changing the reference to that file in
> the data dictionary.
>[color=green][color=darkred]
> > > I write code to high standards because it
> > > has to be held up as an example to all other programmers in my team.
> > > If you take a look at
> > >
http://www.tonymarston.net/php-mysql/dateclass.html you will see an
> > > example of my coding style. Notice how I break up groups of code with
> > > blank lines, notice that I use lots of comments. Also notice how I
> > > break up the regular expressions into their component parts so that
> > > even someone new to regular expressions has a chance to understand
> > > them.[/color]
> >
> > Those are merely style issues. While they are certainly important, I don't
> > think they are that relevant to this discussion.[/color]
>
> But that demonstrates that I can write code which is just as readable,
> and therefore maintainable, as anyone else. This should be the major
> issue here and not "you cannot use that feature of the language in
> that way". I must be free to use whatever features of the language
> that are available in whatever combination I choose in order to
> achieve a result. Provided that the code I produce is well structured,
> well documented and can be read, understood and maintained by others
> should be the only yardstick. If someone can point to a piece of my
> code and say "if you used this bit of code instead of that it would be
> more efficient" or "are you aware of a poptential bug in this area"
> then I would be prepared to listen. Constructive criticism is always
> welcome, but non-constructive criticism is a waste of time.
>[color=green][color=darkred]
> > > Unfortunately all of the "best practices" I have encountered in the
> > > past have been the best that a particular individual or small group of
> > > individuals can do, and not the collective knowledge of the whole
> > > programming community.[/color]
> >
> > If you have had no experience with the best-practices I've been talking
> > about, then why do you still seem so hostile against them?[/color]
>
> Because I see no reason to believe that the "best practices" you are
> talking about are any better than the examples of "best practice"
> which I have encountered in the past 20 years. My idea of "best
> practice" is what produces the best results in the shortest possible
> time, while others seem intent on creating a set of innefficient rules
> and sticking to them regardless of how long it takes to produce the
> results.
>[color=green][color=darkred]
> > > But telling them that there is *only
> > > one way* to do things is quite wrong, just as it is wrong to say that
> > > there is *only one true religion*. It is correct to identify the
> > > difference between different methods, such as "this is faster to
> > > implement" or "this has fewer bugs" or "this is easier to maintain",[/color]
> >
> > But saying "This is better because it leads to better maintainability/faster
> > code/fewer bugs" presumably isn't.[/color]
>
> If one method has more advantages and less disadvantages than another
> then it can certainly be said to be better. But as far as ths thread
> goes nobody has offered me any proof that my method is worse than
> theirs. They just assume that just because it is different it is bound
> to be inefficient and unmaintainable. Some people have suggested
> alternative methods, but I have yet to see any advantage in adopting
> them. I will not change my methods unless I see a distinct benefit in
> doing so.
>[color=green][color=darkred]
> > > An individual's creativity must
> > > be allowed to shine otherwise everything will remain the same and
> > > there will never be any progress.[/color]
> >
> > But it is certainly a shame when an individual's creativity is wasted on
> > rediscovering stuff that has been known to fellow craftsmen for decades.[/color]
>
> But different groups *know* different solutions to similar problems,
> and my point is that there will never be just one solution to any
> given problem. Every solution is *right* and no solution is *wrong*.
> Just because there are 100 possible solutions already out there should
> not prevent me, or anyone else, from creating solution 101.
>[color=green]
> > Reinventing the wheel doesn't exactly generate much progress.[/color]
>
> I am not reinventing the wheel, just devising a different process for
> making one, and I am receiving abuse from certain quarters just
> because I have created a methodology which is different from theirs.
> The fact that the results of my design are just as efficient and
> maintainable as anyone else's does not seem to enter the equation.
>
> Tony (you do it your way and I'll do it better) Marston
>
http://www.tonymarston.net/[/color]