Saturday 18 February 2006

How Do You Store Your Previously-Written Code?

How Do You Store Your Previously-Written Code?: "I don't. Not in the sense you're after...
(Score:5, Informative)
by LoveMe2Times (416048) Alter Relationship on Friday February 17, @02:48AM (#14740636)
(http://slashdot.org/ | Last Journal: Monday April 21, @06:50PM)
I've been programming for 20 years now, and I've worked in a variety of languages during that time on a lot of different things. And you know what? All of the code that I ever wrote before has pretty much zero value now, with a few exceptions. Especially at your phase of development as a coder, I think you'll find the value of code reuse after significant time has elapsed practically non-existant. Why? Well, because you'll find that your abilities grow substantially every couple years, and you're almost always better off to start with a clean slate rather than fooling around with your old code."

Now, there's a few caveats here. Another thing that happens over time is you learn to stop re-inventing the wheel and to use pre-existing libraries. Right now, you're just unaware of their existence, but you'll learn where to look if you make a little effort. In fact, you'll find that existing libraries tends to heavily influence choice of language to use. So it turns out that most things that are really worth reusing are already available, and you should use those solutions rather than maintaining your own. Sure, write your own for fun or education, but when you get a serious project, you've got no use for it. In some cases, you'll find that there's no library available, so you write something from scratch, but 3 years later, you find that somebody else has made a nice library that's much better than what you hacked together. Several times I have ported code from my own hacked together solution to a more mature library. It's a natural progression, and there are a thousand times more libraries freely available today versus 10 years ago.

Now, having said all that, there are still times where you want to make something that is generically reusable. The point is, though, you should really make an effort to make a library out of your code. I have done just this on a handful of occasions. Then, put it up on SourceForge or something similar dedicated to your language of choice. I have a few libraries up on SourceForge, some only a few hundred lines of code, but some other people have found them useful because I made the effort. Other people have suggested CVS or whatnot, and SourceForge will give you that.

Maybe the real gist of your question, though, was about making your code into a library? While the technical details of making a lib, dll, so, jar, pm, etc vary from language to language (sometimes compiler to compiler), here's a few pointers:

  1. This is just good practice in general, but you have to make the code *independant*. It has to stand on it's own. You might have heard about encapsulation, this is what they're on about. Make sure your application code no longer has to make any assumptions about how the library works. Get rid of "magic numbers" and define well-named constants. Make some effort to make the libraries data protected so app code can't screw it up.
  2. Make all of your functions meaningfully named. Make sure each function sanity checks it's inputs. Return meaningful errors anytime something goes wrong. This can be the hardest part. You have to check for and return errors *rigourously*.
  3. Define error constants, and provide a function to get a meaningful error message as a string. Alternatively, if you're using exceptions, make sure the exceptions can provide a message as a string.
  4. Provide appropriate initialization and cleanup/shutdown routines. Clearly define whether or not the library or the application "owns" any resources (memory, file handles, database connections, sockets, and so forth) so people know whether or not to release them.
  5. Make an effort to decompose your functions to expose a fine-grained interface, and then write "convenience" functions that use the low level functions to implement common needs. For example, if you have something that opens a file and processes it, break that down into something that works on a memory buffer and provide a convenience function that opens a file and feeds it into the memory buffer version. That way, somebody who uses a different file API, or sockets, or a database, etc can still use your memory buffer function.
  6. DON'T over-generalize your code prematurely. This is a judgement call. Go ahead and write in support for logical or obvious extensions and scenerios you deem likely, but otherwise try and let things be demand-driven.

After you work with more libraries made by other people, you'll get a better sense of what to do.

Finally, if you really find the need to keep random code snippets around because you tend to forget how to do certain operations, I *strongly* urge you to PRINT the code snippet onto paper, label it reasonably (how to create a window, how to connect to a database, how to do a regular expression search, whatever), and put down the website, book, helpfile, or google search terms necessary to find it again! Then, put these in a folder that you keep at hand. It makes it easy to find and take with you, and also (hopefully) prevents you from making copy-and-paste errors. More important are the references so you can find more information. Between the amount of documentation/tutorials that are electronically searchable and the books on my shelf, I personally find this to be a waste of time.
=========================

Re:Oh - My - God

(Score:5, Insightful)
by theStorminMormon (883615) Alter Relationship <ngivens AT richmond DOT edu> on Thursday February 16, @08:51PM (#14739201)
I can't believe his age is even being discussed. He could be 33 for all I care. since when is it a crime to ask a question? Again - he's not wasting anybody's time. Anyone who resonds to this thread to complain about him proves they have the time to deal with the issue at least a little bit.

I think it's crazy that some poor guy manages to get his question posted on slashdot - which means he's probably going to get a wealth of information - and he ends up having the legitimacy of his question debated in terms of his age!

It's people like this that give techies such a bad reputation. It's one thing to laugh in fun at the dumb users who try to use the CD-drives as cup holders. It's another thing to get irritated with users who expect us to fix their messes after the screw stuff up. But to smack down someone who's actually trying to learn to do it on their own because you don't like their question? That's just elitist and anti-social.

-stormin
--
It's never a question of whether or not the ends justify the means. The means determine the end.
==============
by menkhaura (103150) Alter Relationship on Thursday February 16, @11:05PM (#14739843)
(http://rootlinux.com.br/)
It may be all you *need* to get started, but I'm sure you know that PHP's OO these days is quite stellar. PHP 5 classes are now complete, with the whole OO shebang: polymorphism, encapsulation, interfaces, C++-like exception handling... the only thing that it doesn't support, and I'm not sure it *is* strictly necessary, is multiple inheritance. For the rest, you should try PHP 5, it is a very mature language and, IMHO, quite suitable for general purpose programming, not only web pages, even more so with the recent release of PHP-QT (there is already a PHP-GTK if that's your poison) for stand-alone GUI applications.
--
Sed quis debugget ipsos debugger?
=================
////////////\\\\\\\\\\\\\\\\\\\\\\\
by Anonymous Coward on Thursday February 16, @08:20PM (#14739041)
The Microsoft mindset can be summed up in four words: You can buy anything.

It doesn't matter what it is you want; maybe you want to control a market, maybe you want to manufacture a quality video game console, maybe you want to create a public perception that you are a good company, maybe you want to be found innocent of breaking the law. For all problems, there is exactly one solution, and it always works: throw money at the problem. If this doesn't work, then increase the amount of money you throw.

Here we see the logical end conclusion of this kind of thinking. In this case, what Microsoft wants is users for its mediocre also-ran search engine. And the way they are attaining this is to simply buy some, by paying people to use their search engine.
============
////////////////////////

Why, back in my day!

(Score:5, Funny)
by Bananatree3 (872975) Alter Relationship on Thursday February 16, @11:33PM (#14739960)
(http://forums.krazyletter.com/)
14.4k was for the rich, and we were lucky enough to even own a computer! Harrumph, these techie-wizbang whipper snappers...downloading everything in sight, always wanting things FASTER and FASTER!. Harrumph I say.
--
Krazyletter Forums [krazyletter.com]
===================
by Animats (122034) Alter Relationship on Thursday February 16, @11:38PM (#14739984)
(http://www.animats.com)
With ad blocking, dialup can be faster than low-end broadband with ads. Well over half of bandwidth is consumed by ads.

Sites that work just fine at 56K:

  • Google
  • eBay
  • Slashdot
  • Fandango (movie tickets)
  • FedEx
  • Digi-Key
  • Craigslist
  • Yahoo

The primary use of broadband is to deliver ads. At the consumer's expense. No wonder 30% of users don't want it.

====================Only 8 sites? No wonder so many people are switching to broadband.

----------------------

Some facts (based on Q3 2005 numbers):

80% of the South-Koreans have broadband, 75% of Hong Kong, 60% of Israel, 60% of Taiwan, ~57% of Singapore, 55% of The Netherlands, 53% of Monaco, 53% of Canada, 51% of Switzerland, and 50% of Denmark. (source: http://www.marketingfacts.nl/images/uploads/200601 -point-topic-boradband.gif [marketingfacts.nl])

The following is also interesting to see: http://www.marketingfacts.nl/images/uploads/per-ca pita-income-vs-broadband-uptake.gif [marketingfacts.nl]

Growth broadband in percentage first half year of 2005: http://www.marketingfacts.nl/images/uploads/europe -broadband-map-q2-2005.jpg [marketingfacts.nl]

And Eastern Europe is very active right now revamping a lot of their telecommunication systems so that will mean that in the coming time their broadband penetration will soar as well.

----------------

////////\\\\\\\\\\\\\\\

What is a rootkit?

(Score:5, Informative)
by tom6a (871216) Alter Relationship on Friday February 17, @04:31AM (#14740923)
If you are looking for a good reference to understand a rootkit I recommend Matt Vea's article "Rootkits: The 'r00t' of Digital Evil." He wrote it back in Novemeber when the Sony fiasco was first revealed. Link: http://www.omninerd.com/2005/11/22/articles/43 [omninerd.com]
==================
\\\\\\\\\\\\\\\\\\\\\\\

Godwin's Law: missing the point

(Score:5, Insightful)
by meringuoid (568297) Alter Relationship on Friday February 17, @08:31AM (#14741848)
Godwin - preventing legitimate discussion in the 'net since 1990!

The reason Godwin's Law has caught on so strongly is that it's a useful rule of thumb. Once a discussion on USENET has reached the point where people are citing the Nazis, chances are it has long ago stopped being worth reading.

However, there are circumstances in which comparisons to the Nazis are not unreasonable and cannot be put down to the usual hyperbole found in flamewars. This discussion is one of them. We are dealing here with American corporations doing business in a totalitarian state, and - through the nature of the business they are doing - aiding and abetting the unpleasant regime there in the very deeds for which they are despised.

In the 1940s, it was IBM supplying the machinery needed to handle the great indexes and lists needed to keep track of the processing of six million or so undesirables, and the consultants and technical assistance needed to set up and run that machinery.

Today, it is Yahoo handing over the emails of activists, and Google censoring search results. Is this quite the same scale of evil as IBM's collaboration in the Final Solution? No. Is it, however, qualitatively the same, even if it is quantitavely lesser? Yes. Just as happened back then, our corporations are collaborating in the sordid work of tyrants.

Godwin's Law, therefore, cannot be applied. Comparisons to the Nazis are clear and appropriate.

--===========================
by Angostura (703910) Alter Relationship on Friday February 17, @07:47AM (#14741522)
I heard the snippet of inquisition on the radio and regardless of my feelings about Google et al's activities in China, I though the congressman's question deserved an answer which highlighted it's stupidity.

Lantos asks:

Well, IBM complied with legal orders when they cooperated with Nazi Germany. Those were legal orders under the Nazi German system...Do you think that IBM during that period had something to be ashamed of?

The answers should have been:
Are you saying that the current Chinese regime and the Nazi regime are equivalently evil? If you are then my answer to you is that not only IBM but the whole of the U.S.A had something to have been ashamed of during that period.

The U.S.A had yet to enter the war despite evidence of what the Nazi's were up to. They had yet to implement full economic sanctions against the Nazis.

If, congressman, you believe that the Nazis and the chinese are comparable, why hasn't the U.S declared full economic sanctions against China, and why hasn't it made illegal for any U.S company to do business with that country? Why have you yet to propose that we declare war against China?

The truth is, because China is not equivalent to Nazi Germany, and your question is nonsensical.
=====================

Re:Double Standard

(Score:5, Insightful)
by jcr (53032) Alter Relationship <jcr&idiom,com> on Friday February 17, @07:12AM (#14741318)
(Last Journal: Saturday November 05, @05:26AM)
Ah yes, it is those EVIL tech companies support the EVIL chinese regime by following the law and not the US government which has given them the Most Favored Trade Status with the US.

It would appear that you're trying to let google off the hook, just because another organization (the government) has also dealt with the criminal regime. Sorry, morality doesn't work that way. Having company doesn't excuse a crime.

=================

Tom Lantos

(Score:5, Informative)
by kcurtis (311610) Alter Relationship on Friday February 17, @07:20AM (#14741354)
In general, I would agree with you. However, you are off base on this one because it was Tom Lantos making these statements. He is a HUGE champion of freedom (true freedom, not freedom unless it hurts a corporation). I have taken the liberty of doing a cut & paste of part of his online biography:

An American by choice, Tom Lantos was born in Budapest, Hungary, on February 1, 1928. He was 16 years of age when Nazi Germany occupied his native country. As a teenager, he was placed in a Hungarian fascist forced labor camp. He succeeded in escaping and was able to survive in a safe house in Budapest set up by Swedish humanitarian Raoul Wallenberg. His story is one of the individual accounts which forms the basis of Steven Spielberg's Academy Award winning documentary about the Holocaust in Hungary, The Last Days.

Say what you will about most Congressmen, Senators and the President, but complaints about MFT and coddling those commie bastards doen't apply to Rep. Lantos.
==============

Re:Absurd.

(Score:5, Insightful)
by Cederic (9623) Alter Relationship on Friday February 17, @08:12AM (#14741680)

>> demonstrating without a warrant

Sorry, I need permission to express my displeasure about something?

>> Those people jailed at Guantanamo Bay are also there for their ties to terrorism

Bullshit. Utter tosh and nonsense. Please provide references. Please also explain how holding them there without trial, legal representation, the ability for individual private interviews with representatives from the UN, while interrogating them with abusive techniques is in any way justified even if they do have ties to terrorism.

Just what is terrorism anyway? I do recall considerable amounts of US support for those very people in Afghanistan when they were fighting against the Russians that are currently being targeted by American "anti terrorist" operations now.

Hypocrisy? Hell yes. I don't give a shit what the background of Lantos is, I don't care whether he votes against MFT status for China or not; the organisation he represents is very far from being the champion of freedom and democracy it would have to be for his questions to those companies to have any credence at all.

Shame? I hope to hell he feels it.
============================hey! Cedric: the last #5 -rated comment, and the only
one shrewd enough to state what is obvious to ME, which is the OBESE SHAME of the damn
war criminals throughout this damn hoaxed govt that stomp on little people EVERYWHERE....
mercilessly and sharelessly and what a vile arrogance of 'Christian' 'Liberators' and good-do-ers.



0 Comments:

Post a Comment

<< Home