|
Im currently learning several coding languages and something i have come across a lot, is that i can learn how to do something easily enough, i can figgure out a way to implement what i want into my project, but this isn't necessarily the best way to do things.
I am aware that there are usually multiple ways to do things, and they can also boil down to either good, simple, readable code, or terribly messy code, that takes way to long to do anything, is possibly a waste of time, and cannot be read by anyone other than the coder.
In an attempt to learn to code proper, ledgable scripts, it would be particularly handy to know the things that people do to make their work "good". For example, sure, you could rewrite that four lines of code a hundred times over each time you want to use it, but you could turn it into a method, saving space and readability.
I think it would be particularly useful to learn these "tips" early. There are many things that books teach us, but they rarely get into how something could have been done better, and WHY its better to do that.
Just an idea
|
|
|
|
|
Grubious wrote: I think it would be particularly useful to learn these "tips" early. There are many things that books teach us, but they rarely get into how something could have been done better, and WHY its better to do that.
Oh boy - that's a tough idea, as this basically comes down to instinct and experience. A lot of times it comes down to doing something wrong and learning from it - and experienced programmers do this just as much as newbies. This normally happens when the experienced developer moves onto a new technology - one that they are going to take some time getting up to speed in.
What I would say though is that the best piece of advice I can give to a newbie is to design a piece of software before sitting down to code it. By analysing the requirements and the possible solution, you start to see where things like patterns fit in. Then - start off by coding small segments. Improve the code incrementally. If you suddenly find yourself in an if statement, 15 layers deep then it's time to step back and look at where you've gone wrong.
|
|
|
|
|
The best advice I can give you is not to complicate things in the first place. Keep to the 'one function does 1 thing' rule, one class represents 1 concept and as soon as it's 1 and a bit things then break it down. Never be afraid to add files to the project, classes to the hierarchy or functions to the next version of the interface. Never write specific code where an instance of generic code will do the job and document just 2 things, intent and the semantics of arbitrary names. In other words always write down what it was you were intending by the code you wrote and what the semantics of int iSomeNumber are supposed to be. I've only really done medium and large scale project in BASIC and C++ but I'm sure these principles apply to whatever development platform you're using.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
|
And what should one use insteads?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Use ints whereever possible, or decimal if you are dealing with something currency.
If you ignore floating point inaccuracies, they can add up and make the result completely incorrect. Even simple calculations like x^2-y^2 can return results that are wrong in every digit.
But floats are no black magic, rounding errors are not random but completely predictable; and you can prevent them from adding up by designing your algorithms correctly (e.g. replace x^2-y^2 by (x - y)*(x + y)).
If you use floats/doubles, read this: http://docs.sun.com/source/806-3568/ncg_goldberg.html[^]
|
|
|
|
|
The best method? Read books[^]. I always find a good book more useful sometimes when trying to learn something than reading stuff on the internet. Even printing off stuff rather than reading it on screen helps because you're less likely to be distracted and more likely to completely read the information now that you've gone to the effort of printing it off.
Another thing I'm finding particularly useful is to read certain blogs, for example, many people don't agree with what Atwood at CodingHorror[^] says but I have to say that on every topic so far I've agreed with him.
Given the current climate (as in temperature) here in London I'm planning to once my exams are over either take a copy of Code Complete out of the library here at Imperial, or buy myself a copy, a book which I've always been meaning to read. Then using the two weeks I have after exams before I drive back home sit in Hyde Park every day and read through it. I know many people can't just go to the park every day for two weeks but you could set yourself an hour or so aside each day to read a book or even printed articles from this site.
When I was getting the bus to and from school each day then I used to use that hour for reading books, not always programming, so if you have a commute on public transport each day then it's a perfect time to read a bit. Even if it's only 10 minutes, as long as your sufficiently prepared and get the book out when you get on then you can do quite a bit of reading in that time.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
an excellent suggestion; time permitting i may (humbly) attempt an article on the topic. in the meantime, some suggestions:
0. always remember that people (users, developers, managers, salespeople, etc.) are part of the system; consider their needs; talk to them; if the users don't want the system or don't like the system, the project fails, regardless of how perfect the design/code may be
1. normalize - eliminate redundancies everywhere possible
2. generalize - in many cases solving the problem in front of you is complicated and verbose, while solving the more general problem (of which the problem in front of you is just a special case) is easier.
3. simplify - make everything as simple as possible, but no simpler [great Einstein quote]
4. quantify - if you don't know how to measure it or test it, you probably can't design or code it either
5. explore - never be afraid to conduct experiments; some things cannot be understood until you start out on a path in some direction
good luck!
--S
|
|
|
|
|
Hi to some background ,I want to invoke RMI call to a server ,and I have written the following client code ,that access a getCounter()to show the incremented static variables value ,each time calling the getCounter() will increment the static variable by 1.That code is deployed in the server.
PDOS_Remote_Interface service1 =(PDOS_Remote_Interface)Naming.lookup("rmi://x.xxx.xxx.xxx/REMOTE_SERVICE");
String s1= service1.sayHello();
int cont1 = service1.getCounter();
System.out.println("&;&ggtt;>>>> "+s1);
System.out.println(">>>>>> cont1 "+cont1);
PDOS_Remote_Interface service2 =(PDOS_Remote_Interface)Naming.lookup("rmi://y.yyy.yyy.yyy/REMOTE_SERVICE");
String s2= service2.sayHello();
int cont2 = service2.getCounter();
System.out.println(">>>>>> "+s2);
System.out.println(">>>>>> cont2 "+cont2);
This is working fine with even two different server (I mean in two physically different machine(x ip and y ip) ,there ip are different )
with following output :
>>>>>> Server Says Hai!
>>>>>> cont1 0
>>>>>> Server Says Hai!
>>>>>> cont2 0
that is static variable is not shareing as they are in two different server
Now My problem:
I want to hit the one and only server ,In this case Service1 and Service2 are getting the remote instance from only one machine .And when I am doing that I am getting the static variable incremented ,That is following output
>>>>>> Server Says Hai!
>>>>>> cont1 0
>>>>>> Server Says Hai!
>>>>>> cont2 1
Is this possible to create two JVM instance in a particular machine ..??
I mean I want the first output (both static variable shows 0)in second implementetion (using only one machine )???
|
|
|
|
|
Having looked through the crap below and lurked in the lounge for a while I'm almost willing to brave the article thingy. I know I'm a fairly lousy writer and the ideas (2) I have are not so much coding genius as ways of getting around problems that I have run against in everyday work. Titles are:
How to use SSIS to load a csv file with variable column numbers and repeating column names
How to launch Clickonce deployed apps using the command line.
Question is should I attempt these or are they a waste of time. There is no revelotuniary code involved just convoluted thinking.
[edit]Oh and where is the template that was around, I will NOT use the wizard - talk about an invitation to lose your man points [\edit]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you think its something worthy you spent a night on and it solved some issue, i suggest do post it!
Btw you dont need to invent a space-ship before writing article...am working on couple too dont tell anybody
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
I've been mucking around with Script.Net[^]. My intention, eventually (or never, as the case may be), is to provide my applications with a scriptable interface in the Excel/VBA style.
Of course, me being me, I came up with a bunch of questions - which would take me decades to solve - which I reckon an article by any-one of the gurus here could have done before breakfast, specifically:
-How to provide a consistent and usable object model
-How to properly integrate scripts in a coherent way
-How to implement a script execution context and security model with a nod towards "trust" and signing
-How to be flexible enough to accommodate different scripting languages - I'm thinking about the DLR here: allow users to script in their language of choice (Iron: Python, Scheme, Lisp, Ruby etc etc)
-How to provide an inbuilt IDE for scripting (personally I'd just bug leppie for an xacc.ide component )
-How to stop a bad script from breaking your application - offering roll-back facilitates for when the user makes a boo boo.
-How to make any such framework flexible enough to be cross-application
-And I had some other ones, which I can't now remember.
Anyway, I thought it might make for an interesting read/project for those of you with the skill/time/know-how especially as we head towards the Dynamic .Net era.
|
|
|
|
|
Good idea. I implemented ActiveX scripting support, Javascript and VBScript, for a product similar in scope and intent to Powerpoint about 7 years ago, a large and fascinating project. There's no way I could write an article on it now as I've forgotten most of what was involved but I can recommend downloading the source of the Microsoft ActiveX Ccontrol Test Container. It implements pretty much every ActiveX container side interface ever concieved and the source, amazingly for MS, is pretty readable and well laid out. In terms of object model I'd say stick as close as reasonably possible to the way Office does it, Application, Workspace and Document objects. I can't even concieve of how you'd make anything reusable across aplications and I have no idea how hosting for Python etc works but I'd definitely be interested to find out.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
martin_hughes wrote: How to provide an inbuilt IDE for scripting (personally I'd just bug leppie for an xacc.ide component )
Or you could try the new VSX Shell? Overkill probably but at least you've got a good base to work from, plus if it was completed then it'd be a great IDE to work in . Not that I want to criticise Leppie but at the moment it's still very much his code and he'd have to do all the work on integrating it and he always seems to be spending his time going off writing LISP these days
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Ed.Poore wrote: Or you could try the new VSX Shell?
It's quite nice... but when your scripting environment dwarfs your application by several orders of magnitude, you have to take pause for thought
|
|
|
|
|
martin_hughes wrote: but when your scripting environment dwarfs your application by several orders of magnitude
Hmmm, I suppose but you'd actually be putting in less effort using something like VSX because that's what it's been designed to do.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Any takers?
|
|
|
|
|
|
If I login and click on My Artitles....how do I EDIT an existing article ? The article was also submitted without even allowing me to finish the article. also, how do I SAVE an in-process article ? You need to review the simplicity of the Codeplex and MSDN code submission application for some ideas.
|
|
|
|
|
First off, this is probably in the wrong forum. I believe this is better suited for the Suggestions/Site bugs, their you might be able to get a better answer then what I am about to tell you.
If the article was edited by a CodeProject staff member, then you cannot edit the article through he site, you will have to email a site representative to request a specific change to be made. If the article has not been professionally edited, then you should be able to see a 'Modify' link on the top right of the article if you are logged in. Once their, their is a nice wizard to guide you through the process of editing the article. If the article was half way through the submission wizard and then the wizard crashed, then that is a bug to point out in the forum mentioned previously. If the article has been deleted because it was not up to the standards of the CodeProject once submitted, then you cannot edit deleted articles.
Codeplex and MSDN submission applications are for an entirely different audience then the CodeProject.
[Edit]
[If you want to save an article that is in process, you have two options: A) Save the article on your hard drive for when it is complete and up to CodeProject standards; B) If the article is already up to CodeProject standards, then you can submit it and then edit the article with processes mentioned previously)
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
I'm going to start a new project - a small (but very user friendly) accounting software. I'm looking for some general tips, advices and experience - mostly technical. Can you point me to some articles, e-books?
btw. I'm not a noob, I just want to go with the best practice I can find.
Thank you.
|
|
|
|
|
Lju2 wrote: I'm going to start a new project - a small (but very user friendly) accounting software. I'm looking for some general tips, advices and experience - mostly technical. Can you point me to some articles, e-books?
This forum is for people to request or suggest ideas for articles. It's not for programming questions. Your question would be better placed in the 'General Discussions' forum.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
You asked the perfect question and I have the exact program you are looking for. However, because I am using the program/code in a National programming competition I can't release anything
The one I wrote:
-8,000 lines of code
-300 hours to create
-handles vendors->POs->Invoices->Check Register->Reporting->User Management->Check sheet printing, etc
I am bummed that I cant share more of the program, but if you need assistance just post back. I might be able to help a tiny bit.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Have you consulted any books, articles before developing your application?
Followed any other design, already made?
Thanks
|
|
|
|
|
My accouting program uses WPF and as such I looked at various reference books on WPF including: Pro WPF, Pro C# with .NET 3.5 Framework, and a few others.
As for the accounting aspect, the entire program was written from scratch with only my ideas to work from. I did not consult any reference material for the creation of this program. I did however get more fine-tuned accounting details with regards to the accounting requirements for the program from other people.
As for the design, my application is one of a kind, and I have not seen another application similar to it in the market.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|