Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good programming practices versus speed of ad-hoc programming [closed]

Tags:

c++

I know good programming practices always help in the "long run" for a project, but sometimes they just seem to cost a lot of time. For instance, its suggested that I maintain a header file and a cpp file for each class that I make, keep only the declarations in the headers while definitions in cpp. Even with 10-12 classes, this process becomes very cumbersome. Updating the makefile each time a new class is added dependecies and evthing .. takes a lot of time...

While I am busy doing all this, others would just write evthing in a single fie, issue a single compile command and run their programs ... why should I also not do the same? Its fast and it works?

Even trying to come up with short, meaningful names for variables and functions takes a lot of time, otherwise you end up typing 30 character long names, completely unmanagable without auto complete

Edit :

Okay let me put it a little differently : Lets say i am working on a small-medium size project, that is never going to require any maintenance by a different developer (or even me). Its basically a one time development. Are programming practices worth following in such a case. I guess my question is, do the good programming practices actually help during the development, or they just pay off during maintenance ?

like image 429
AnkurVj Avatar asked Oct 18 '10 19:10

AnkurVj


People also ask

What is ad hoc approach in programming?

Ad-hoc in the domain of competitive programming means that question does not require any prerequisite knowledge of any algorithm or data strucutre or high level mathemtatical concept; and can be solved using basic logical skills or sometimes even by common sense.

What are ad hoc coding problems?

The Ad Hoc problems are problems that cannot be classified anywhere else in the categories with well-studied solutions since each problem description and its corresponding solution are unique. These problems don't fall under standard categories, there is no specific or general technique exists to solve them.

What is an ad hoc question?

Ask a Question. When we say “ad hoc”, we usually mean that you do not need to apply a sophisticated algorithm to solve the problem; instead you will write something specific to the problem at hand.


2 Answers

I haven't been working in the field for long, but not slacking off and documenting as I go, defining variables with useful names, etc...definitely saves time in the long run. It saves time when the other developers/myself go back to the code for maintenance.

Not stuck wondering what this variable means, why did I do that, etc! :)

like image 77
Ashley Grenon Avatar answered Oct 27 '22 00:10

Ashley Grenon


Laziness may pay off right now, but it will only pay off once. Taking the time to do it right doesn't pay off immediately, but it will do so multiple times and for a longer period of time.

Also, there is nothing wrong with really long variable and method names, unless you subscribe to the naive view that most of the time you spend programming is used on typing and not solving problems.

Addendum: If it is hard to name succinctly, it probably needs to be broken down into more modular units. Method or variables that are hard to name is a definite code smell.

like image 35
JohnFx Avatar answered Oct 27 '22 01:10

JohnFx