Jan Nowak

Greenhorn
+ Follow
since Aug 12, 2007
Merit badge: grant badges
For More
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jan Nowak

Hello,

Thank you for the great book on new release of Flex. I have a couple of questions related to architecture of large (say 250+ screens) Flex enterprise applications. I am not sure if your book contains architectural topics but it would be good to have something about Flex application architecture.

Here are some of my questions:

1. How Flex application should be structured? Which design pattern is good fit for Flex? MVC, MVP, MVA, MVVM? At which level these patterns should be used (components level, individual screen level, application level that manages navigation between these screens)?

2. What building blocks can be distinguished when implementing Flex application and what should be reusable? Components, widgets, screens? Which design pattern should be used for building each of these components?

3. How to decouple screens so that one screen knows nothing about the other but at the same time they can "talk" to each other? For example one screen requests other screen and wants that other screen to have some fields to be defaulted, enabled/disabled, preloaded etc.?

4 How would you implement field level security in Flex? Some buttons/actions/fields etc. are visible/enabled only when user has a permission to see that button/control and only when certain business conditions are met?

5. How Flex application should be designed for modules or pluggable architecture? Loading modules based on permission, communication between screens packaged in modules?

6. Would you recommend TDD for Flex application? If so what should be tested - "C" and "M" when using MVC but not "V"? Which design pattern should be applied when building Flex application in order for them to be easily unit-testable? Or unit-testing doesn't make sense for Flex applications only functional testing with tools like QTP, FlexMonkey etc.?

7. Large applications quickly become spagetti code and event bus in Flex easily helps with that (especially bubbling option). Do you have some best practice recommendations to use events or just passing reference or some other recommendations when building Flex applications?

Thanks
14 years ago
As far as I know this is perfectly legal.
From Angelica Langer FAQ on generics:

You can declare a reference variable of an array type whose component type is a concrete parameterized type. Arrays of such a type must not be created. Hence, this reference variable cannot refer to an array of its type. All that it can refer to is null , an array whose component type is a non-parameterized subtype of the concrete parameterized type, or an array whose component type is the corresponding raw type. Neither of these cases is overly useful, yet they are permitted.



So these are allowed:


[ November 25, 2007: Message edited by: Jan Nowak ]
You have to watch for other cases too (these are taken from here):




Output:
1 // variable i of I is constant and you don't have to initialize it
j=3 // j is inherited from J so J must be initialized, so jj gets initialized as well
jj=4 // but notice that k of K doesn't get initialized nor super interface of J that is I
3 //output from K.j

Also:



Output: 1729
but not: Sub 1729

a reference to a class field causes initialization of only the class or interface that actually declares it, even though it might be referred to through the name of a subclass, a subinterface, or a class that implements an interface


And here:


Output:
99
[ November 23, 2007: Message edited by: Jan Nowak ]
The price unfortunately varies from country to country. $200 applies only to USA. In Europe for example the cost for the exam is: Germany 210 EUR, UK �150. When you register on Sun's website and provide different country than the USA in the address field, then you are redirected to a page with a list of regional offices of Sun. You must buy SCJP voucher from that office in the country in which you are going to take the exam.
I think the answer should be: there is 1 object eligible for garbage collection. In this code the object Short story = 5; is not eligible for garbage collection because it's creation is optimized by the Java compiler. Remember that values between -128 and 127 are shared by Byte, Short, Character and Integer objects. You can easily check this concept and the answer to this question:


And for the above code the answer should be: one object is eligible for garbage collection.

However in this example there are 2 objects eligible for garbage collection:


[ November 17, 2007: Message edited by: Jan Nowak ]
Thank you for your answers. I was confused because I thought that with calls like l.get(0) the compiler ALWAYS adds a cast. It means that compiler adds it when necessary.

But still I am not clear about why in the second example the compiler binds the call to println(Object) and not to println(int) (autoboxing should work here) since it can distinguish String and bind the first call to println(String).




However, the code indeed does not compile... because it's missing a semicolon on the second line.



Sorry, I didn't notice that. Now it is correct.
[ November 13, 2007: Message edited by: Jan Nowak ]
I am confused about this code:


Here I understand that compiler adds cast to String and therefore we have exception. But consider this:


Here I thought that there will be exception as well because of cast added by the compiler but it is ok. Can anyone please explain me this?
[ November 13, 2007: Message edited by: Jan Nowak ]

what could be the difference between the constructs while(true) and if(true) ?



There is a difference between while and if in such cases. It has to do with flag variables used by programmers for testing or other similar activities. if statement treats if(constant) assuming that constant can be changed later. The problem is described here.
Hello,

When we have a static synchronized method in a subclass is the lock acquired for super and subclass or subclass only?


My question is, when method run invokes metB from B is lock for A.class and B.class acquired or lock for B.class only? Both methods access static variable a that is defined in A so there can be concurrent access problem when second thread accesses metA in class A. And what about situation in which static method form superclass is redefined in subclass, is there any difference?

When synchronization is involved does it mean that lock for the object (or class) and all the locks for its superclasses' objects (or classes respectively) are acquired?

Thank you in advance
[ October 14, 2007: Message edited by: Wielki Szu ]
To resolve this example you should know operator precedence, check here. Because x-- have the highest precedence among the given operators it will be evaluated first, then x/0 and then - so the expression
x---x/0 will be:

x-- - x/0

In the example:
int x=8;
System.out.println("x value:"+(x---x/2));

the result is 5 because you have to remember that x-- is a postfix operator and it is applied after the whole expression is evaluated.
Check here (see the tables) for different cases when making mathematical operations on different variable types.
[ October 08, 2007: Message edited by: Jan Nowak ]
Final instance variables must be initialized before constructor completes - so K&B book says. Brian's code is changing final value in a constructor. Try doing it in an instance method.
Hello,

Is it possible to create reference variables of arrays of generic types like:

OR


Here, I found that we can declare a reference variable of an array type whose component type generic. But all such variable can refer is null, an array whose component type is a non-parametrized subtype of the reference variable component type or corresponding raw type (List[]).

But when I try to declare reference variable to an array of generic type I get an error that "arrays of generic types are not allowed". I know they are not but the FAQ says that declaration of a reference variable to an array of generic type IS allowed. Can someone check is this true. My compiler rejects such declaration. I have 1.5.0-beta version and I compile with -source 1.5 flag.

One more question. Do I have to learn all the details of generics in order to pass SCJP 1.5? I have read K&B book, but the chapter about generics is too short and doesn't explain generics in detail. I had problems with questions about generics on the self test after the chapter. So I decided I have to strengthen this objective and I found this useful FAQ. But it is so big. Do I have to know all the details about type erasure, bridge methods or subsuitable return types for the SCJP? Do you have a link to generics tutorial that is not so advanced but enough to pass SCJP?

Thanks.
[ August 29, 2007: Message edited by: Jan Nowak ]
Hello,

Thanks all of you guys for your responses. So static methods can't be overridden but they can be hidden and rules for hiding static methods are the same like for overridding methods. I got it now. The compiler message confused me but now I understand, thanks.