Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

application design questions.

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Few simple questions about the designing an oo application:

1.How to design a method so that its return type value is never null.
Are there any design strategies to follow?

Also is this statement true - "calling method must not make null checks on the return type of the called method"?

2.Should the exception handling design be done in the initial design iterations, and get expanded as the application requires more exceptions?

3. In a MVC pattern based application, if the client layer recieves the payload in a valid xml format from a different service:

Which of the following are the good practices to implement attribute level invariant checks like the data type, min/max size and default values:

3.1. implement the checks in client tier while validating the incoming xml aganist its xml schema by having the checks as part of the schema.

3.2. implement the checks only in the middle tier.

3.3 implement the checks both in the client and middle tiers.


Thanks in advance.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These have the scent of homework on them. What have you done to find the answers? What do you think the answers are so far?
 
Srinivas Ramgopal
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. How to design a method so that its return type value is never null.
Are there any design strategies to follow?

>>>>My thoughts - If design by contract (having method pre and post conditions and class invariants) is implemented then there are very slight chances of null situations in the normal workflow. Inspite of this, if nullpointerexception rises, then log file can be checked if logging the messages where ever felt appropriate is maintained in the code base.

When is the usuage of Null Object design pattern appropriate??

Also is this statement true - "calling method must not make null checks on the return type of the called method"?

>>>>My thoughts - Yes, it is true. I was dumb in asking this question.

2.Should the exception handling design be done in the initial design iterations, and get expanded as the application requires more exceptions?

>>> Yes, it is true. Dumb again!

3. In a MVC pattern based application, if the client layer recieves the payload in a valid xml format from a different service:

Which of the following are the good practices to implement attribute level invariant checks like the data type, min/max size and default values:

>>> If xml schema validation can be done at the client tier to handle all the data validation, I was not sure whether it can be replicated at the business tier in terms of keeping the tiers loosly coupled.

Your input is highly appreciated.

thanks in advance.
[ August 19, 2006: Message edited by: Srinivas Ramgopal ]
 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"srinu kcr",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Srinivas Ramgopal
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I updated my display name and profile a moment ago.

Thanks.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for filling in what you have so far. It's much easier for the rest of us to start from there than from scratch. I'm going to hit just one topic ...

We recently had a long discussion about returning null. It's common for null to have special meaning. For example, we might say a zero length string means "user submitted an empty field" and null means "user never entered this form". I thought there was a pretty convincing argument that this is "bad" because the method signature can't warn you there might be nulls or give you any hint what they mean. It's also bad because it requires all callers to check for null. And they have to read the doc or get a null to know that.

So, your proposal to define methods to not turn null and use a post condition check to make sure is a good start. How would you like to handle the difference between entered blank and never entered anything?

I like NullObject though I've only had a couple opportunities to use it. One was a suggestion from an instructor that we have many, many tests like this:

To eliminate all those tests (and the risk of forgetting one) I made a "null transaction" so we could always call commit(). The method in the Null Object did nothing at all.

I wonder if an acceptable answer to your question is "return primitives".
 
Srinivas Ramgopal
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the prompt reply.

Your question - How would you like to handle the difference between entered blank and never entered anything?

>>> My thoughts - I believe that in both cases, an exception needs to be thrown if the field is required in the database.

Regarding null object pattern usuage - Can a method call on a different service in SOA based applications, return null OR an object (based on null object pattern) that contains the reason to return null OR throw a user defined exception with the reason???

Also how to analyze as when to use null object pattern??
It looks like if the design by contract and the method parameters being 'not null' checks are made, there is no need to use null object pattern. Are there any other design strategies that I am missing??

Your input is highly appreciated.


Thanks in advance.
 
Bras cause cancer. And tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!