wood burning stoves 2.0*
The moose likes Cattle Drive and the fly likes com.javaranch.common and servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "com.javaranch.common and servlets" Watch "com.javaranch.common and servlets" New topic
Author

com.javaranch.common and servlets

Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
My initial reaction to "having" to use the JavaRanch Common LogServlet for the assignments was pretty much grumble grumble. After reading up on servlets and getting used to how examples looked it seemed like a drag to have to get into this big class and figure out (sort of) how it works compared to the almost familiar look of other servlets.
Then I think it dawned on me (I think). Yeah it's kind of a drag, but reading "homemade" code is not necessarily easy, even when it comes so well commented and documented as Paul's. The point that gets underlined is about not expecting to always see code just like it comes straight from the API.
Is dealing with "someone else's homemade code" (with all due respect) intended as part of the process here?
Out there where real programming happens, do developers deal with other people's code as much as, or even more than, their own?
All that to say, in the end I appreciate the exercise, it seems to make understanding code in general a tad bit easier.
*one more grumble just for good measure*
[ January 30, 2002: Message edited by: Pauline McNamara ]
Michael Pearson
Ranch Hand

Joined: Mar 11, 2001
Posts: 351
Yep, I agree with you. It is a good exercise to read Paul's code and figure out how it works and how to use it. Almost too "real world". I don't think I've ever commented a program as efficiently as Paul does.
My first reaction to the Servlet exercises was, "Gee, I know how to do exercise 5, how am I going to do the others"?

[ January 30, 2002: Message edited by: Michael Pearson ]
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
    
    2

My initial reaction to "having" to use the JavaRanch Common LogServlet for the assignments was pretty much grumble grumble.

I know what you mean. It annoyed me at first. But using the common code, I was able to do the assignments up to 4a and write a prototype for an application (you know the one...)before consulting any reference on servlets other than the Cattle Drive assignment page.
But I'm always getting these nitpicks "Did you notice a similar method in javaranch.common?"
Note that in Servlets-5 you can't use the common code. For practice, you can always rewrite the earlier servlet assignments without the common code. I found that to be a useful exercise.

Out there where real programming happens, do developers deal with other people's code as much as, or even more than, their own?

Depends on what you mean by real programming and by developers. Job-title-wise I'm an "application developer" (formerly a programmer/analyst -- same job, different title). Although I get to do some development, much of my work is maintenance programming, which is chiefly enhancements and fixes to existing code. Some of the code is original to my organization, but the bulk of it is from a commercial product (yes, we have rights to the source). So for any change to the commercial code, we have to think in terms of whether the vendor will release an update, fix, enhancement, etc. and what will the impact of our changes be when it comes time to reconcile our modified version with their new code.
I might study hundreds or even thousands of lines of code for several days, do all sorts of testing, then change or add 10 lines (not counting comments). No, stop laughing, I'm *completely serious*. If you think the ratios are exaggerated, think again.
All this in a horrific, ugly procedural language (in which variables are global by default <shudder>).
Reading the Java API source code or javaranch.common is a *joy* compared to the code I deal with on the job.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Originally posted by Pauline McNamara:
Yeah it's kind of a drag, but reading "homemade" code is not necessarily easy, even when it comes so well commented and documented as Paul's. The point that gets underlined is about not expecting to always see code just like it comes straight from the API.
[ January 30, 2002: Message edited by: Pauline McNamara ]


Better not be a personal dig
And I totally agree with y'all. Doing the servlet assignments with the Java API versus Paul's was, originally, my way of thinking. I did the same thing, did 5 first, and then tried to figure out the rest. However, once you get used to it and get really familiar with what is going on, it is quite an effective solution (is this a pattern of some sort, or just a nice way of doing it? I seem to see Facades and Adapters everywhere now).
From everything my OO Engineering and OOAD instructors have said, both of which have been working with Java almost from its inception, the majority of the time they are looking for ways to use code that is already there. That's the whole point of OOP, reusable code. Most people that I talk to, they do exactly what Mike said. But heck, I would rather be doing that than NT server junk.
Just as a heads up. I started doing the JDBC assignments using Java's HttpServlet API, and was told "why don't you go back to using the javaranch.common stuff" (that's a paraphrase). Sorry Marilyn, hope I didn't ruin a nitpick for ya *cackles*
Jason
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
I have a hard time slogging through the code that is provided with the common file. A lot of it doesn't make any sense to me at all, probably because I do not have a programming background. It seems that some of the solutions are more complicated using the code provided there, at least from a conceptual point of view. As far as attempting to do Assignment 5 first, are you guys NUTS??? I have no idea as to how to procede with that one. Servlets are truly kickin' my butt! But, I will not give up.
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
    
    2
Originally posted by jason adam:
However, once you get used to it and get really familiar with what is going on, it is quite an effective solution (is this a pattern of some sort, or just a nice way of doing it? I seem to see Facades and Adapters everywhere now).

LogServlet (albeit an abstract class) extends HttpServlet, so it looks like plain old inheritance to me.

Most people that I talk to, they do exactly what Mike said.

Remember though, I'm in a procedural shop. None of that reusin' business going on around here. One of the training guides for SQR (the main language I work in) suggests "clone, Clone, CLONE" as a technique for building programs.
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
    
    2
Originally posted by Carol Murphy:
I have a hard time slogging through the code that is provided with the common file. A lot of it doesn't make any sense to me at all, probably because I do not have a programming background.

If you have specific questions and you don't think they would give away any solutions to assignments, why not post them here? Would that be on-topic, moderators? It might be fun to discuss some of the common code, as long as we're careful not to give away anything about assignments.
I'm thinking things along the lines of the conversation we had here about a week ago about LogServlet and Exceptions.
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Originally posted by jason adam:
Better not be a personal dig

No way. I even considered mentioning how muddling through LogServlet and co. at the same time as getting to look over your shoulder while you wrote the log updater app was a great immersion opportunity.
Your code is so readable to begin with *blush*, penciling in my own comments doesn't take much.
At my last job, we contracted a firm to analyse some code and a whole bunch of their time was spent adding in the comments to a program that had none. Really, not one, for pages and pages! And the original program wasn't free!

Just as a heads up. I started doing the JDBC assignments using Java's HttpServlet API, and was told "why don't you go back to using the javaranch.common stuff" (that's a paraphrase). Sorry Marilyn, hope I didn't ruin a nitpick for ya *cackles*
*joins in cackle* hehe thanks, Jason
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Originally posted by Michael Matola:
For practice, you can always rewrite the earlier servlet assignments without the common code. I found that to be a useful exercise.
I agree, that's how I've been going about it. Actually, first with HttpServlet then with LogServlet.
I might study hundreds or even thousands of lines of code for several days, do all sorts of testing, then change or add 10 lines (not counting comments). No, stop laughing, I'm *completely serious*. If you think the ratios are exaggerated, think again.
Wow. Do you enjoy this part of your work? (Not a sarcastic question.)
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Originally posted by Michael Matola:
If you have specific questions and you don't think they would give away any solutions to assignments, why not post them here? Would that be on-topic, moderators? It might be fun to discuss some of the common code, as long as we're careful not to give away anything about assignments.

I think this is a great idea.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Yup, I agree, don't think it would be off topic at all. Since many of the assignments deal with javaranch.common, I see no reason why we couldn't discuss some of the code there, from a reasonably high enough level.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
How high a level are we talking about?
Seriously, some of this code leaves me completely befuddled. If the assignments weren't so clearly explained, I don't think I would be able to go much further because of the gigantic voids in my understanding of what has come before. Without knowing what this code is replacing or improving upon leaves one a rather confused little puppy.
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
    
    2

Originally posted by Pauline McNamara:
mm > I might study hundreds or even thousands of lines of code
mm > for several days, do all sorts of testing, then change or
mm > add 10 lines (not counting comments). No, stop laughing,
mm > I'm *completely serious*. If you think the ratios are
mm > exaggerated, think again.
Wow. Do you enjoy this part of your work? (Not a sarcastic question.)

Tough question. Especially since I'm in a bit of a funk right now concerning my work.
I like figuring out how things work. I like tracking down bugs. I like fixing things that are broken. But it doesn't compare to doing development, in my opinion -- it's not nearly as creative, and the boudaries are too constrctive. The goal is often to fix things such that your changes are minimally disruptive the existing code. I usually want to make far more sweeping changes than I'm allowed to do.
But it is experience with code, nonetheless.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Originally posted by Carol Murphy:
How high a level are we talking about?
Seriously, some of this code leaves me completely befuddled. If the assignments weren't so clearly explained, I don't think I would be able to go much further because of the gigantic voids in my understanding of what has come before. Without knowing what this code is replacing or improving upon leaves one a rather confused little puppy.

Well, I'm thinking asking questions without showing code. Basically, the same way you would ask a question here about one of the assignments. Not all of the classes in the package are used in the assignments, of course. Just want to make sure we don't let slip anything that causes the student not to learn.
Jason
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: com.javaranch.common and servlets
 
Similar Threads
code coverage tool
Passed with 86%
How about this, will this help?
Make code appear larger?
Are you ready for some football?