Welcome to Dream.In.Code
Click Here
Getting Help is Easy!

Join 117,542 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,697 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



reusing code

 
Reply to this topicStart new topic

reusing code

jediokie
post 15 Mar, 2008 - 08:49 PM
Post #1


D.I.C Head

**
Joined: 7 Feb, 2008
Posts: 175


My Contributions


I have noticed a reoccurring theme in my Programming I course. That is we really reuse many of the same code snippets to do multiple assignments. Is this because it is a real world situation when you code? Or, is it just that there is not a lot of variety with ANSI C?
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 15 Mar, 2008 - 08:52 PM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 5,421



Thanked 35 times

Dream Kudos: 2350

Expert In: Goofing Off

My Contributions


QUOTE(jediokie @ 15 Mar, 2008 - 08:49 PM) *

I have noticed a reoccurring theme in my Programming I course. That is we really reuse many of the same code snippets to do multiple assignments. Is this because it is a real world situation when you code? Or, is it just that there is not a lot of variety with ANSI C?

When you get paid by the hour, you can rewrite stuff as much as you like. However, when you have a dead-line, you'll be a copy-&-paste fool!

It's been my experience that you only want to reinvent the wheel so many times. Chances are, the next time you might miss something, or accidentally let a bug slip by. If it works, use it.
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 15 Mar, 2008 - 09:06 PM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 11,894



Thanked 24 times

Dream Kudos: 25
My Contributions


Reusing code is one of the main goals behind the concepts of functions, objects, and data structures. That is efficiency, in any language. Any programmer worth his salt should be reusing code wherever possible (and appropriate).
User is online!Profile CardPM

Go to the top of the page

PsychoCoder
post 15 Mar, 2008 - 10:43 PM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,831



Thanked 80 times

Dream Kudos: 8050

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI, Boo.Net

My Contributions


Reusing code is the sign of a quality programmer, as Amadeus pointed out. From my years as a programmer I have amassed tons of code snippets I use everywhere. Once you find code that works, and works efficiently make sure to keep that piece of code in a safe place for later use.

As no2pencil pointed out, there is no need to reinvent the wheel every time you need a piece of functionality. As your reservoir of code grows, your programming time decreases as you will have code snippets pre-made to accomplish many of your tasks.

You will also notice, with time, that there are truly only so many processes, its not like its a infinite number. And once you've been in this business as long as some of us have you end up with tons of reusable code at your disposable. This is really nice with contract work, it takes less programming time because you have some of it already done before you ever take the contract.
User is online!Profile CardPM

Go to the top of the page

Tom9729
post 16 Mar, 2008 - 06:19 AM
Post #5


Debian guru

Group Icon
Joined: 30 Dec, 2007
Posts: 1,428



Thanked 10 times

Dream Kudos: 325
My Contributions


I usually try to write generic, modular classes/source files. That way I can easily reuse them in new products.

An example would be a FileIO class.
User is offlineProfile CardPM

Go to the top of the page

tody4me
post 17 Mar, 2008 - 09:30 AM
Post #6


Only Jenny Craig makes thin clients...

Group Icon
Joined: 12 Apr, 2006
Posts: 1,056



Thanked 3 times

Dream Kudos: 100
My Contributions


Every company I've worked for and written code for, I've first come up with what I call my utility library. It handles all the tedious tasks that I find myself always using. Such as in C# I use Excel for reporting, instead of say another reporting utility. So I write a wrapper for the PIA's (version that the company is using) and use that everywhere. Something that I always wrap is the data handling functions, and if I use text files I will write something to handle the tedious task of opening and reading (.NET has a great class for this, but what I want it to do is open the file and give me the data in a table or array).

This post has been edited by tody4me: 17 Mar, 2008 - 09:30 AM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 05:28PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month