Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!

Peter Kovac

Ranch Hand
+ Follow
since Aug 08, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
10
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Peter Kovac

Hi,

You can use the import resource to import any file specified by a Java System Property. So if you have something like:

and you pass -Doverride="/config/my_override.xml" to java it should be imported by Spring.

Also you can try to use Spring Profile if you're on Spring v3.1 or newer.

Regards,
5 years ago
Hi,

I have a code like this, where Foo is passed to Bar (e.g. by Spring wiring):


Will UML look like this or is it a simple dependency?

Thanks,


Sorry.. I wanted to ask which version to prefer:

1. create the StatusList class and use it everywhere like method(StatusList lst)
2. use a simple ArrayList<Status> as the implementation and use List<Status> in arguments like method(List<Status> lst)

I guess (2) is preferable and in that case there's no reason to bother creating a StatusList which is essentially the parameterized ArrayList.
So the conclusion should be that if the domain class does nothing besides parameterizing the generic list and giving it a (domain) name it should not be used..
5 years ago

Paul Clapham wrote:If you have an informal architecture like that, then yes, it doesn't really matter how you structure things.


So either the StatusList or List<Status> is fine? Should we use List<> as it's an interface?
5 years ago

Paul Clapham wrote:So (for example) any code can add a new Status object to the list at any time?


Yes.. the users of this class are expected not to break system intentionally.
5 years ago

Paul Clapham wrote:And therefore the question is "What is the intent of your StatusList class?"


It's just a collection of statuses, if it exposed more functionality I would go for the domain class, but as it is used only as a replacement for an array of statuses I don't really know if that's the way.
5 years ago
Hi,

A lot of sources recommend creating business/domain objects to clarify intent (Clean Code recommends this practice when passing boundaries pg.115):

We are not suggesting that every use of Map be encapsulated in this form. Rather, we are advising you not to pass Map s (or any other interface at a boundary) around your system. If you use a boundary interface like Map , keep it inside the class, or close family of classes, where it is used. Avoid returning it from, or accepting it as an argument to, public APIs.



so If I have a Status class is it ok to create a domain class like this:

to be used as an interface to the other modules in the system instead of List<Status>?
On the one hand you will have a "nice" domain object but on the other hand you will loose the flexibility of the interface.

I'm inclined to use this approach (or using composition) only when StatusList actually adds some functionality but some colleges prefer having domain classes every time.
Anybody has any experience on this?

Thanks for you answers,
5 years ago
I guess the answer is that emptyMap returns a custom Map implementation.
5 years ago
Hi,

If I have a class

why can't I use it in methods expecting Map<K,V>

e.g


I know the raw type of HashMap<String,String> is HashMap but EntityStatusMap is not a HashMap?

Thanks,

5 years ago
Hi,
I have the following question:

The Java Servlet Specification v3.0 pg104 says:

The error page mechanism described does not intervene when errors occur when invoked using the RequestDispatcher or filter.doFilter method. In this way, a filter or servlet using the RequestDispatcher has the opportunity to handle errors generated.


What does this mean?
If I have a web.xml with customized <error-page> section and I use sendError from a doFilter method, will the custom or the default error page be shown?

On the other hand how is it possible to skip the customized <error-page> and return for example 404? Use setStatus?

Thanks,
6 years ago
Thanks I found the DefaultServlet as the root app.
But is there a reason why you have different behavior between deployed applications and root by default? I mean should they just show the same error page if no customization is done?
6 years ago

Bear Bibeault wrote:The first two will be handled by whatever's installed as the ROOT web app. So no surprise that they're different from the last, which is handled by your web app.


Thanks. Do you how can I configure the root web app? Where's it located? My WEB-INF contains only my application.

6 years ago
Hi,

My question is why there are different error pages for the same 404 status.

E.g:

http://my.server.com -> returns empty page / no content / status=404
http://my.server.com/invalid_app_context -> returns empty page / no content / status=404
http://my.server.com/app_context/INVALID -> returns the usual error report page / status=404


I've an application installed in app_context in the last request but the URL is wrong for it.

Thanks,
6 years ago
Thank you guys.. what's the book you recommend on this topic ?
6 years ago

Jesper de Jong wrote:I would say yes - why make an abstract class when it's not necessary? That only adds code, making your program longer and more complex for no benefit.
Sometimes it is beneficial to provide an abstract class, especially if you want a default implementation for some of the methods of the interface. If you then make multiple concrete classes that have to implement the interface, you can make those extend the abstract class, so that they inherit the implementation of the methods from the abstract class.



Thanks.. But if we have only an interface and a implementation class we can just start by having a class and then extract an interface as the need arise.
The issue I see here that if we have an interface then we can refer the class by the interface and not the concrete class, but if the class is not to be extended for the foreseeable future then the interface might just add another level of maintenance..

Also if we have an abstract class we can start separating concerns over a general abstract class and a specialized implementation very early that can be more expensive if we need to re-factor the structure later.

Do you have any experience how much burden the one abstract class-one implementing class scheme add to the maintenance for a longer term in an enterprise code base?
6 years ago