Post #142,986
2/24/04 9:40:30 AM
|
Depending on the language...
PL/SQL objects (in 8i at least) required that the constructor have a parm for every single member in the class. If the class represented a huge table, the results were serious pain.
This has changed in 9, fortunately.
Not the case for your code, obviously.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #142,988
2/24/04 9:44:12 AM
|
LRPD
"The results were serious pain."
-drl
|
Post #142,991
2/24/04 9:57:33 AM
|
This is written in Java
The people who wrote this system thought they understood OO but really didn't. This is a system with methods hundreds of lines long, where many of the catch clauses are for Exception (in fact when I catch individual exceptions, in code reviews they tell me why write all those lines just catch Exception), a love of utility classes and static methods, etc. Whenever I suggest that a class should be responsible for some behavior directly related to itself, many times the answer is, write a utility class or a static method instead. This led to a completely idiotic database layer, instead of using a normal OO - Relational mapping tool they did the following.
select = DatabaseQueryFactory.createSelect(); \t\t\tselect.addField(DBScheme.MngObj.ENTITY_CONTAIN_LIMIT_cols.ECL_AMOUNT_LIMIT); \t\t\t// add conditions
\t\t\t// first filter by customer ID on the containing id \t\t\tselect.addCondition(DBScheme.MngObj.ENTITY_CONTAIN_LIMIT_cols.ECL_CONTAINING_ENTITY_TYPE_ID, \t\t\t\t\t\t\t\tCondition.EQ, EntitiesTBP.TypesEnum.CUSTOMER); WhereClause filter = new WhereClauseImpl(); \t\tfilter.add(new ConditionImpl(DBScheme.MngObj.CUSTOMERS_cols.C_CUST_ID, Condition.EQ, customerID)); ...
To say I am a bit frustrated is an understatement.
|
Post #142,993
2/24/04 10:13:40 AM
|
Nasty.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #142,995
2/24/04 10:44:47 AM
|
Brings back bad memories
I took a job that sounded like it would be fun - writing financial code in C. The chief coder was sort of a dork but he had good equipment in the place and sounded like he was on top of things.
First day, I start looking over this code - it's hundreds and hundreds of lines long, if statements that went on for pages, tons of static variables, stupid use of h files to define functions - about every bad C practice you could imagine.
Some time in the first week he calls me into his office. I factored some of the tortured stuff he'd written into a manageable form and formatted it sensibly, and used ANSI prototypes and made sure everything had a defined type.
He didn't know what "void" was. This guy is hopping mad because he doesn't know what "void" means. Then he starts in on the reformatting. Then the naming convention I used. Then the factoring into smaller functions. On and on. He had no standard, but mine was unacceptable. He didn't know how to actually write C code, but mine was unacceptable.
I lasted 2 weeks (enough to get 1 paycheck). Never forget his name - Richard call me Richard. "Mornin' Rich." "It's Richard." "OK."
You should get a chance to look over code before taking a coding job. The funny thing is, that shitty Java you're looking at was probably written by someone whose resume was loaded with Java and was filled with various whoppers. H1B maybe. Expert.
-drl
|
Post #143,061
2/24/04 2:53:01 PM
|
Interesting point
The company I currently work for is a very successful software company that is growing. I expected to come in and be impressed by their development skills, processes etc. After 3 months, I am amazed that they can get a product out the door. The best people I ever worked with were some ex-Smalltalkers who had a small consulting firm and worked for a large bank. We worked on Java from 1997-1999 and did some amazing stuff. I truly believe that Smalltalk programmers are some of the few who really grok OO. C/C++ people usually think they do but don't.
|
Post #143,087
2/24/04 4:48:46 PM
|
Re: Is written in Java?
Remeinds me of some stuff from a Ukrainian outsourcing company I had the misfortune to encounter last summer.
[persistance code longer and uglier than straight JDBC [but not _quite_ as ugly as your example], MFC style naming conventions infecting Java code]
|
Post #143,176
2/25/04 2:42:31 AM
|
Yes, by people with C/C++ (MFC) experience
|
Post #143,167
2/24/04 11:48:24 PM
|
Two points
Er...PL/SQL - from 7+ at least - can do either positional arguments or named arguments.
ie: foo ( argument1, argument2, ... argumentN) or foo ( arg1=argument1, argN=argumentN, etc)
2nd - create a second constructor and use polymorphism to reduce the number of arguments.
ie: foo (argument1, argument2, ... argumentN) foo (argument1, argument2) { foo(argument1,argument2, argument3 = null; argument4 = null; ... argumentN = null)) };
|
Post #143,196
2/25/04 8:41:28 AM
|
Re: Two points - well, you're half right.
1) Correct, but this has nothing to do with the point I was making.
2) Incorrect. In Oracle 8 there is one constructor, which takes all of the object's members as arguments. This is required as you may not set default values for arguments in the constructor. The workaround is to create static factory methods (NOT constructors) that internally create default values and call the system constructor with all of the attributes set appropriately.
I'm not quite sure why you called this "polymorphic", either. There ain't no sich thang in Oracle 8i. What you're talking about is "overloading", which can be done in 9.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #143,211
2/25/04 10:23:58 AM
|
"Static factory methods", constructors - what's the diff? (new thread)
Created as new thread #143210 titled [link|/forums/render/content/show?contentid=143210|"Static factory methods", constructors - what's the diff?]
[link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad] (I live in Finland, and my e-mail in-box is at the Saunalahti company.)
You know you're doing good work when you get flamed by an idiot. -- [link|http://www.theregister.co.uk/content/35/34218.html|Andrew Wittbrodt]
|
Post #143,352
2/25/04 7:54:45 PM
|
You're right...
I was thinking of the parameter passing aspect of PL/SQL (from 7+), not the constructor aspect they added in later on.
You're quite correct also, that I'm thinking of overload rather than polymorphism. I had also switched from Oracle to Java (because I still don't think of PL/SQL as OO language).
I'm not sure that a static factory method would be required in this case for Java, if the constructor can be overloaded to default the values.
|
Post #143,394
2/26/04 12:09:33 AM
|
Not required in Java.
The default constructor in Java sets no values at all, in fact.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|