sigh... I feel so tired.
I completed my Java Assignment submission in class today. I had it debugged and working 10 minutes right before the end of the class. I got it demo~ed to my tutor who was impressed with me. Whee~
I'm really happy I got my HD 'cause this is one of those rare times that I feel that I deserved it.
on JAVA...
Java J2EE Specification
I now understand the nature of EJBs and sessions. The remote interface class and the corresponding EJB class must have the same number of corresponding methods, that return the same data types and that throws the same exceptions. Because, it is after all, an interface.
And another thing, please note that EJB classes are NOT tightly coupled with the Data class.
An example, you have a set of EJB classes that define your Projects table in your database. Refer to your ISYS2049 wk07ex03_v2 work Chris.
Your EJB classes are:
1. Projects.java - your remote interface class
2. ProjectsHome.java - that initializes and creates your EJB container
3. ProjectsEJB.java - contains your business logic.
4. ProjectsPK - the class that defines the primary key of your table
So your ProjectsData.java class is where the data from the database fields are kept in the session. They have NOTHING to do with the EJBs. So, you CAN change the data types in your Data class and just have your corresponding variables's data types in the EJB classes correctly parsed.
the Low Coupling, High Cohesion pattern...
I had then built my own validation package in Java. With methods to check if an input is an int, long, or some other primitive type.
This is for my future reference. (not bragging...)
I did this by building a method that enclosed what I wanted tested (a String type input from a web form) in a try-catch block. By then having what I want validated parsed from the String type into the primitive type I wanted, I could then throw an error that returned a boolean type false back to the calling method.
example of Validation code...
public boolean isInteger(String stringIn) {
System.out.println(" isInteger : " + stringIn);
try {
// could be substituted for some other primitive data type
int validInteger = Integer.parseInt(stringIn);
} catch (NumberFormatException e){
System.out.println(" isInteger : " + stringIn + " - FALSE");
return false;
}
System.out.println(" isInteger : " + stringIn + " - TRUE");
return true;
}
goodnight people...
I got to learn so say no to people...
I've decided to stop helping people with their coding stuff for the interim. A lil' sick with people asking me for help on their Java and .Net stuff, especially when I don't really know them. Crys? you know you are special exception. Heh!
I just want to get my own stuff done first.
Reading some Robin Hobb now. Kwang, if you see this man, go get her the Tawny Man trilogy...
Fool's Errand
The Golden Fool
Fool's Fate
Or 'course you're welcome to borrow it off me when I get back to KL man... Heh! It's the continuation of the Farseer and the Liveship Traders trilogy. I guess you now know why the story ended quite so abruptly in those books.
I'm going to go get some shut-eye now.
2 comments:
Sorry to burst your bubble dude but all lanugages carry the cast checker. Python is the only language so far that i've used where the method is a bit longer than others (C and C++ for example). Catch (error message manipulator) is abundant in C++ as a test tool. Nevertheless, what you've got there is not bad i suppose. Well, try credit card validation. That's harder too. Especially if the raw is in MD5, and you have to use brute force... All the best anyways CK
Every language carries a cast checker? Erm. Thats true...
But I wrote something really simple to show that there is no need for the system to throw an error but you can actually manipulate the error as you build a validation class.
And last I checked, I couldn't find a ready built cast-checker in the Java API. Though I could have sworn I've used something like a isNumeric() before (could be from .Net 'cause I do both).
I've yet to try credit card validation though. @_@ Verifying datetime and datetime conversions are as bad I've dared and they are a nightmare to manipulate.
Thanks for the knowledge sharing man.
Post a Comment