Your personal tricks for code re-use
I'm working on my monthly column for Software Test & Performance magazine, and I'd like your input.
Agile and extreme programming methodologies are based on code re-use. That makes plenty of sense, but it assumes that you can find what you need... even if you aren't looking for it. After all, most of us have at least three cordless screwdrivers, because you never know where you left it the last time. It's faster and cheaper to buy a replacement than to putter around, searching for the screwdriver in the garage and getting distracted by other things ("Wow, I forgot I even owned a basketball"). And that doesn't count the search for the charger.
Does your software development work the same way?
If Agile and Extreme Programming are all about code re-use, then how do you get your SCM tools (or any other tool) to advertise the existence of code that might be available for reusing? That is, it's one thing if you remember, "Hey, I worked on something similar, 3 projects back; let's search through that code to see if any of it will save us time."
But what if your memory is poor, or you're new to the team? How do you find out about the code you didn't remember? Isn't that how teams re-invent the wheel (and have to debug the wheel), or wind up with 5 modules that do the same thing?
I'd like to hear about the ways you organize your software garage... er, that is, your SCM tools... so that you can both find what you KNEW you had around here somewhere (i.e. search for code you remember writing in a previous project) and also get some sort of "Hey! I can do this for you!" advertisement from your personal or corporate stash of existing work?
From my initial conversations with developers, I suspect that the answer to the first part (searching for an answer you KNOW exists) is much easier than the second (code advertising its existence or suitability to the present need). If that's so, what's the result? Despite best intentions, do you write new code (that is, buy a new cordless screwdriver)? Do you build or wish for or buy tools that claim to solve the second issue, in addition to the first?
I have to hand in my article by the end of next week, so it'd be great if you could share your opinion with me (publicly, here, or by private e-mail to [email protected]) before June 15th. Please be sure to let me know how I can refer to you in the article ("Joe Jones, a programmer at FooBar Corporation in Orlando, Florida"), or if we have to find another way to cite your input ("Joe Jones, a programer at a financial services company in the southeast U.S.").
Esther Schindler
contributing editor, Software Test & Performance magazine (stpmag.com)
Re: Your personal tricks for code re-use
Generally speaking, I'm involved in developing/keeping current/ or improving four projects at once.
They generally relate to:
data mining of binary objects...
Reading and Downloading contents of directories VIA ftp/UrlDownloadToFile...
Manipulating Incoming,Unprocessed PDF's to Impossed Output PDF's that meet with Bindery Expectations...
Accessing Database INFO for reading and writing purposes.
Now, I mighty be developing New versions or maintaining old versions.
Either way, I generally try to reuse Code that I've developed, unless I have time to streamline.
Its very rare for RAD programmers to streamline. So, basically, we tend to cycle in our development in terms of the type of progie we are currently developing.
I rely strictly on memory, since the type of progie I'm developing doesn't change very rapidly.
However, I DO dbase the properties of the systems that I need to read, but that has nothing to do with progying.
-Lou
Re: Your personal tricks for code re-use
So, if you had a project where everybody quit, or the entire development team was run over by a large beer truck, NOBODY would know what code existed?
And the next project, two years from now, will have to start all over?
Re: Your personal tricks for code re-use
Quote:
Originally Posted by NotLKH
Now, I didn't say that!
We have descriptions of our mission critical programs, and backups.
:)
Would those descriptions help a new team -- or a new team member -- learn about the code in each program? Or only about the functional purpose of each module?
For instance, let's say you have some quirky database connection that has to be made. It took you a while to figure out how the leg bone connects to the thigh bone, and YOU sure wouldn't want to figure it out again. I bet the documentation says something like "Perform connection between Leg Bone database and Thigh Bone database," not "uses XML, REXX, and an old dBase IV database, for reasons nobody quite understands."
If another section of the Big App needs that magical connection to happen, you'd call that module again, or at least you'd copy-and-paste the code. Right? But that's because you remembered you had worked on it.
So what happens, two projects from now, when your head has been filled with three other things, and you've forgotten that there was something funky about that transaction. Or you left for a job with a much more impressive salary, so it's the next guy who has to learn it all the hard way. Do you -- does anybody -- have some sort of system for storing the company history of Things We've Written, So We Don't Have To Do It Again?
Re: Your personal tricks for code re-use
Short answer, hmm, even as long answer,
the answer is "No"
What you're asking for isn't a list of "whats been developed" but in actuality extreme commenting of "what this does" on a procedure basis.
Many of the things I develop at times seems mysterious and magical to me, and to devote time and energy to "flesh it out", "make it dummy proof", can and does take more time than redeveloping it.
Many companies need to develop their own progies, but few have the resources {ie.. MONEY} to create a formal development dept.
AND, those that do have a "Development Team" don't have the time or resources to "Dummy Proof" the development.
That, IMHO, is a thing of the past.
Re: Your personal tricks for code re-use
I am a "kid" programmer, in that i am almost 18. I started in VB6 then went to PERL. I have caught myself constantly looking back at old projects and taking code from it and using it in current projects; most of the time it is just for somthing simple, like a few lines that does some loop to split or conver some array to the way i want it.
When i do write "new" code it usually takes almost twice the time than to extensivly edit code that was written earlier. It is also not uncommen for me to look back at code from a different language and convert the code into the current language. Most of the time it is no more than 15 or 20 lines though.
(if you want to use this refer to me as "ALL" and i am an Amature programmer, in that i code almost constantly, but not for any income)
Re: Your personal tricks for code re-use
I've had my own development shop since 1986 - had a partner for a while - now on my own, with a handful of programmers on staff.
For the past 4 years we've been working a single project - that is used in three different business lines - all using the same VB front end and using nearly 1000 MS SQL server stored procedures to perform the business logic.
Most of that is in my mind - 100% of the time. We use Source-Safe to store and organize our routines. We name them intelligently so that they can be found later.
We have developed our own SEARCH utilities to ease finding existing logic.
We have extensive in-house conventions that we force everyone to use.
We make our living on creating custom applications and enhancing them as needs arise.
We architected around this issue - since it's such a huge problem. The mainframe we are converting from had 1000's of individual BASIC programs. Most of these were made up of the same "open file logic" - screen display logic - all a waste of duplicate effort.
We decided that the architecture of a replacment had to be a single VB program - one able to "morph" into whatever business line it need - whether it be high school student attendance or labor union dues payments or municipality payrolls and budgets.
Spending 25 years support 1000's of BASIC programs made us realize that going VB and MS SQL had to be done differently.
I've been involved in large consulting jobs at national health insurance companies. The modification logs and job sheets and program requirement logs were extensive and in my opinion overkill.
Re: Your personal tricks for code re-use
I'm pretty much the same as szlamany - we've got one app with close to 100 activeX controls (which represent the variaous screens in our app. many of which are customized.... man, i can't wait for us to move to .NET) and well over 1000 database objects. We have some pretty strict naming conventions and design methods and practices (such as using VSS) that allow us to easily find a stored procedure or some logic code. We've all been together long enough that our indiviaual way of doing things has blended, and we all pretty much write the code the same way. Everything is modularized, and it hasn't taken long for a newbee to catch on how it all works. Since we are all consistant, it's easy to re-use existing code.
Tg
Re: Your personal tricks for code re-use
Quote:
Originally Posted by szlamany
Most of that is in my mind - 100% of the time. We use Source-Safe to store and organize our routines. We name them intelligently so that they can be found later.
This seems to be a common practice: develop your own naming conventions.
Quote:
Originally Posted by szlamany
We have developed our own SEARCH utilities to ease finding existing logic.
I'd love to hear more about those. What are the search criteria you use? If someone came into your shop and said, "We'd like you to write an e-commerce app for us, and we'll pay you twice as much if you can write it fast," how would you go about finding code, ANY code, that would help you earn that bonus?
Quote:
Spending 25 years support 1000's of BASIC programs made us realize that going VB and MS SQL had to be done differently.
In what ways?
Re: Your personal tricks for code re-use
Quote:
Originally Posted by estherschindler
This seems to be a common practice: develop your own naming conventions.
I would imagine that any size shop would do this - from a MS/ORACLE/COMPUTER ASSOCIATES to a one-man shop...
Quote:
I'd love to hear more about those. What are the search criteria you use? If someone came into your shop and said, "We'd like you to write an e-commerce app for us, and we'll pay you twice as much if you can write it fast," how would you go about finding code, ANY code, that would help you earn that bonus?
The SEARCH program we have developed is like the old mainframe search programs... Specify a folder to search... Specify a filename wildcard to search... Specify a keyword to search for...
It displays all the files in the folder - with the search results. It has a RICH-TEXT-BOX to display the contents of that file if you click on it in the first box. So when you find 3 files match your search, you click on them, and up comes the file with the search criteria highlighted in blue - simple and stupid program.
Quote:
Spending 25 years support 1000's of BASIC programs made us realize that going VB and MS SQL had to be done differently.
In what ways?
We decided that we would only have one program in VB - a single program to support. This program could maintain a student database or a labor union hall database. All the "screen items" and "business logic" would come from the server database - so that the VB client was basically blind-to-the-business application - like WORD or EXCEL. All our business logic is created in T-SQL STORED PROCEDURES - a nice "query" place to do work.
Re: Your personal tricks for code re-use
I tend to reuse a lot of code. I also re use a lot of code because I forget how to do something. I sometimes spend 30-60 minutes digging threw old projects trying to find functions I wrote to do a specific thing for a new project.
Re: Your personal tricks for code re-use
I am not working in a big team at the moment. More or less working on my own. So I have all my code on my computer only. One folder for each language.
ASM
Java
PHP
Prolog
VB
C#
C++
Python
Delphi
and so on, in those folders I have one folder for finished apps, one for apps under construction, and one for reusable code. I also have one Assets folder witch contain Graphics, Music, Sounds, Meshes and so on. When I have finished a stand alone app, I put it in a public folder, so everyone here can reach it through SSH or their Web browser.
We have one server running the real serach engine that I am working on, one test server, and also a local test server on my machine.
http://cdsweb.cern.ch/
So I can get a hold on all code that is released so I can use functions in the libraries all ready written, or copy them into my scripts.
I usualy remember where I have put all my code from the last 11 years, have no problem finding it again. And I am working on 4 OSes now, so it is nice to have a public folder so I can reach it no matter what OS I am working on. But I must admitt that there is probably more code I could have reused if I all ready knew it was written. Like the crawler I made yesterday (it has harvested all night..:)) I was told afterwards that there was an extra function all ready in the library that I spendt 45 minutes to work properly. So some redundant work there will always be. But we usualy get pretty good breefing before we start on a new module. So one of the head hunchos (SP?) here tells us if someone has done something similar.
[Edit] Ohhh...just saw it was deadline 15.Juin now..:)
ØØ
Re: Your personal tricks for code re-use
Quote:
Originally Posted by NoteMe[Edit
Ohhh...just saw it was deadline 15.Juin now..:)
ØØ
It's okay -- it still helped! :D