strategy&word documents files

i have 3 questions

1. the strategy as i understand is a common interface being implemented by more than one class .. and there is a class (which is the strategy) that will instanciate one object of one of those classes (that implement the interface) everytime called.. did i understand the strategy right ?

2. what is a composit .. can someone explain it with an easy example please ?

3. i wrote a document using microsoft word as my user manual, it contains links within the document.. how can i view it in java with maintaining the links? can i run the MS word with the file as a parameter (if so then how?) or is there any better way ?

thanks for helping

[689 byte] By [malrawia] at [2007-9-28 18:52:35]
# 1

Hello,

1) Your understanding of strategy is not entirely correct. Though, operationally you are accurate in saying what you have. A strategy is a concept, that encapsulates an algorithm i.e. logic. Strategy is used in many circumstances, one example is when we want the logic applicable on a data set to vary conditionally (as you may have observed, a simple if..else could be used in this situation, however, that is the point of using a strategy, encapsulating the concern of varying logic).

2) A composit, as the name suggests, is an entity which is composed of many other entities. You can view composit being constructed of smaller entities with various functions, whose total behavior is the composits behavior. It is mostly used when we want to combine together behavior of many concerns together and is most often used in combination with another patter, the "Deligate", where each of the smaller entities take responsibility to do a specific part of the Composits total behavior (this behavior should not be confused witha Proxy or Facade :D)

3) I do not know of a direct way (without going into the encoding of MSWord i.e. RTF) to do this, what I can suggest, however, is to convert the document into an HTML and view it from a Java application (the conversion can be done by MSWord quite easily).

Hope this helps.

Ironluca

Ironlucaa at 2007-7-12 17:10:06 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
hi..i guess i got the idea of the strategy.. but composit not really .. can u give me a simple example please..now about the HTML file what container can view it and is there any method in java that will show the html file ? thanks alot
malrawia at 2007-7-12 17:10:06 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

Hello,

To tell you what is a Composit in simple terms, consider this. Suppose you have a class, which you feel needs to be logically responsible for N functions (suppose identified through analysis). Now, you will most definitely build one class with all the functionality in it (which is neither good form nor in accordance with high cohecion). What you will do, is construct multiple classes (one, let's say for one functionality) and make one class, which acts as the logical container for all the other instances of the other classes (now, here you must not confuse it with proxy or facade pattern, it could be potentially confusing and it should also not be confused with God Class patterns). This container class could be viewed as a composit.

You can view HTML files using classes in the package javax.swing.text.html and javax.swing.text.

Hope it helps :D

Ironluca

Ironlucaa at 2007-7-12 17:10:06 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

hi again .. yes again :)

ok now i am confused between the composit and the strategy they sound pretty much the same - what's the difference between both ?

i checked the classes you told me about for viewing the html file in java but i didn't really figur which one i should use ,i noticed that some of the classes are used to create the document but i couldn't find one that will show it ... which one u recommend ?

thanks

Musab

malrawia at 2007-7-12 17:10:06 > top of Java-index,Other Topics,Patterns & OO Design...