Fixed size table - design pattern
Hello,
I'm wondering what can be the best solution/design pattern for the following situation:
The requirement is to store logs in a table and the user can define the maximum size (in megabytes) of the table. The table usually store 0,5-10 million records in case of normal settings. If the table is full we should drop the old records and log the new ones.
General usage:
Usually the user want to display logs for a special time period so it points to make partitioning based on logging time.
The number of insert in one hour can vary from 1000 to 500.000, but usually it is not more than 5.000.
We are using Oracle 10.2 and all data are stored in LMT.
What can be the best solution for this problem?
Does it really make sense to specify a limit in terms of storage space rather than time? If there is a 500x difference in the number of inserts over the course of an hour, it seems likely to me that users would generally want to keep a certain number of days worth of log information rather than keeping a certain volume in MB. If you ask for a limit in MB, users that use the low rate of inserts would end up with a table so small that if you got to the point of generating lots of records you'd be aging them out far too fast-- those that use the higher rate of inserts would end up with a huge table that has far more history than they need just to accomodate keeping a certain window of log records at the peak.
If you are determined to limit the size of the table, you could potentially run a program periodically that determines the size of each partition (via DBA_SEGMENTS) and then drops the oldest partition if the overall size is too large. But a single partition is likely not to have a huge level of granularity-- you're probably not going to partition by much more than the day, so dropping the oldest partition would purge all the logs for that day. You could potentially get more control over space by not partitioning the table and just deleting the last N rows if you are over the limit, but that probably involves much more frequent checks of space usage and is far, far less efficient in doing the actual deletes.
Justin
Similar Messages
-
I'm creating an rtf template for a master detail report which will be printed over template papers not white papers, so i want to make a fixed size table lets say of 10 rows for details. When i tried to make a table of 10 rows and put the for each loop statement in first row i got table of details + 9 empty rows !! so please can anyone guide me here.
Thanks in advance.Does it really make sense to specify a limit in terms of storage space rather than time? If there is a 500x difference in the number of inserts over the course of an hour, it seems likely to me that users would generally want to keep a certain number of days worth of log information rather than keeping a certain volume in MB. If you ask for a limit in MB, users that use the low rate of inserts would end up with a table so small that if you got to the point of generating lots of records you'd be aging them out far too fast-- those that use the higher rate of inserts would end up with a huge table that has far more history than they need just to accomodate keeping a certain window of log records at the peak.
If you are determined to limit the size of the table, you could potentially run a program periodically that determines the size of each partition (via DBA_SEGMENTS) and then drops the oldest partition if the overall size is too large. But a single partition is likely not to have a huge level of granularity-- you're probably not going to partition by much more than the day, so dropping the oldest partition would purge all the logs for that day. You could potentially get more control over space by not partitioning the table and just deleting the last N rows if you are over the limit, but that probably involves much more frequent checks of space usage and is far, far less efficient in doing the actual deletes.
Justin -
Hi,
I am creating rtf templates for AR Statement, AP Check printing. I created table for printing the invoice details on top, and in the pdf output the XML publisher is printing the table with a length depending upon the number invoices. How to get the table with a fixed length irrespective of number of invoices it is printing. I even tried nesting this table in side the fixed size table with the length I want, but still it is not printing the inner table to full size.
How can I specify the fixed size length for the table in the template?
Thanks,
MaheshI have exactly the same problem.
Canadian friends watch out, the Canadian Payment
Association has set the deadline December 2006. The
Check must be on the bottom of the Check Stub.
Everyone should comply.
But my projects deadline was April 4.
Official Oracle response is:
The Word feature of fixed table sizes is not
supported by XML Publisher.
Oracle suggested the coding as the solution.
The problem is that suggested solution from Oracle is
not working. It introduced new problems.
SR is still open and in status investigating.
Generally, the solution is easy if there is enough
invoice lines to populate whole Invoice section of
the Check Stub. Problem is that in most cases we do
not have maximum number of invoice lines. Some times
there is an overflow where invoice lines are printed
on the next Check Stub page ... next page same
problem ...
At the moment, I think that XML Publisher does not
offer leveraged solution for printing the checks.
If you have any idea please let me know.
Regards,
L.Right -
Design patterns for updating a fact table
I have a fact table and about 10 dimensions.
One of these dimensions can be missing values, so the fact table row will link to an UNKNOWN value.
When the correct value is finally entered in the dimension table i want to update any associated fact rows.
Whats the most efficient way of doing this?I know i have to use a lookup transformation ;-)
I wouldnt be at teh stage of even having a fact table if i didnt know that! I was looking for a design pattern, not the name of a shape!
The solution i went with was to take a hard line on any rows with unknown values. If when importing the data there are unknown values for two of the most important dimensions, those rows are not inserted into the fact table, but instead pushed to an ErrorLog
table.
Users run a report that shows what this table contains and if they really want those rows, they insert the correct dimension values and rerun the import, which will only import any rows not already in the fact table.
This way:
1. all sorting & filtering issues are resolved as there will be no unknown rows for the most important dimensions used in sorting and filtering.
2. we can quickly see any rows with unknown values and figure out whats wrong. its always missing reference data that the client didnt think to give us. a quick insert of the dimension data and import and the rows get imported.
thanks for the replies. -
Dear all,
I have a pool of data which are based organized has CATEGORY and SUB-CATEGORY. When I am configuring the database I should be able to define all categories at once, then being able to define which one is the Parent category of the others.
For exemple if I have a set of Dishes for a restaurant, then I can classify those dishes in different menu category which are then the Parents category for dishes.
Please note that a SUB-CATEGORY can have other sub categories attached.
To have a better idea of what I am trying to do is similar things when you create folders and sub folders on a file system. From the configuration side of the database I should be able to define my category and subcategories and then organize them by a link
ID or other stuff, in the same way I will organize folder.
What will be the best Database table design for that scenario ?
I am not a DBA, but have some basis so try to speak the same language as me :-)
Thanks for help
regardsI think you have it with your design. There are a few ways to represent a hierarchy in SQL, and having two tables like this:
CategoryID CategoryName
ParentCategoryID
1001
Dishes NULL
1002 Desserts
1001
1003 Icecream
1002
SubCategoryID SubCategoryName
CategoryID
10001
Vanilla
1003
10002
Strawberry
1003
10003 Butterscotch 1003
Make sense ONLY if you can guarantee a two level hierarchy (or a fixed number of levels, where you might have yet another table SubSubCategory). Having a fixed number of levels can make processing a ton easier because your queries can be written in
a straightforward manner because the levels of nodes in the tree remain the same.
Your requirements here:
"CATEGORY can have other sub categories attached."
Leads to the more flexible solution like you have set up:
CategoryID CategoryName
ParentCategoryID
1001
Dishes NULL
1002
Starters
1001
1003
Item1
1002
1004
SubCat1
1003
1005
SubCat2
1003
1006
SubCat3
1003
Because adding a subcategory on SubCat3 is as simple as:
1007 SubSubCat1
1006
Processing the hierarchy becomes an iterative process (using a recursive CTE) if you have needs to do a lot of aggregation on groups. There are techniques available to make things go faster than using this pattern in the implementation, but unless
you are going to need 1000s of nodes, then this pattern works great (known as the adjacency list, where you are basically storing the adjacent node in your tree).
Louis
Without good requirements, my advice is only guesses. Please don't hold it against me if my answer answers my interpretation of your questions. -
Does any body have any design patterns of JSF Web Application Developping?
Can any one answer me some questions?
#1.I am an amatuar of people who develop Web Application.For some reason,We choose the JSF to develop our item.through some introduction,I know the UI component of JSF is resided in Server side,is it right?but I am a little confused that:if there are many users who are exploring our jsf website.(to simplify my question,image I had just one web page and just one button)How many UI components(buttons) will be there?How it(they?) works?
#2.Does any body have the success experience (for example design pattern)to develop web applications?if We just concern about the Add,Delete,Modify,Query operations of some data.
I just do my job according to my feeling.
I will give every page a pagebean(backing bean),and I am not sure how to combine the business data with the pagebean.some one suggested that I should use delegate pattern to separate my business log and page logic.But I am still confused by following things:
#2.1 does JSF have the same ability to help us construct the model dialog just like swing to
help us control the operation flow?
#2.2 If there is not,Does the following way work?I put every tabledata's property as corresponed component.if user choosed the row in the table,My Listener will syncronize the row data to the components.But
#2.2.1 if JSF has the components according to the web users' number,how can My Listener tell which component should be update?Should I maintain the map?
#2.2.2 If the problem I imaged above is false,Does any body can tell me how to custom the ListDataModel,so I can use it like Swing?because now I can just use some view data to insert into ListDataModel,but after some selection operation,my business object must be find according to the selected data,it is not an interesting job!
I am waiting for your advice!Ok I'll try to explain Step by step please correct me if I make any mistake because I have not played much with shared variables.
To create a shared variable to an RT target go to the target if tou have already otherwise add an RT target by right clicking the Project>>Add targets and Devices
Then in the target Right clikc and select the variable as shown below.
Then once the Shared variable settings window opens Enter a variable name and then Select the type "Network Published"
In the right side you can select the data type for the shared variable and even you can choose your custome controls.
After selecting the data type go for the Network and select buffering if required else leave it if you are planning to use the variable just for display purpose.
Then you can enable the RT FIFO if required (Not able to explain how it works and why it is used).
Then after completing the Shared variable setup you can access the variable in the VI in both the Host and the RT.
You can bind the variable to a control so that if any data from the RT is coming you can read the data from that control.
Once you have placed your shared variable in the BD you can change the access typr to read or write depending on your need.
This might not explain the complete shared variable concept but I believe that this would defenelty give you a kick off to start using the shared variable. Please correct or add more comments if anybody know better.
Good luck.
The best solution is the one you find it by yourself -
JavaBean Models, Command Bean and J2EE Design Pattern
Hello,
I have read the available "How To", Using EJBs in Web Dynpro Applications where the author mentions that one should use a Command Bean (according to J2EE Design Patterns) so that one can invoke business methods in a Session Bean from our Web Dynpro Application. Well, although, I have read some available articles in the internet about J2EE design patterns, I still have some questions about command beans and its usage in Web Dynpro applications.
I have developed a WD App which uses EJBs to read data from the DB.
Let's suppose I only have two tables: BOOKS and AUTHORS.
Lets also suppose I have to Entity Beans (one for each table) and a Session Bean with two methods: Book[] getAllBooks() and Author[] getAllAuthors();
I also have a Command Bean which I imported in my WD App.
My questions are:
How should I design my Command Bean?
Can I have only one Command Bean with two methods each calling one of the methods of the Session Bean?
Or instead should I design two Command Beans, one for each call?
In the last case do the methods must be named <b>execute</b> or can I name them whatever I want?
Furthermore, how should I store the data in my command bean? In instance variables?
If so, can I use array of a class representing a record in the database table (for instance, classes Book and Author) or do I have to store the data in a generic collection (such as ArrayList for instance)?
I ask this last question because if I try to store the data in an array when I am importing the Command Bean as a JavaBean model I always get an error.
One last question: Can the Command Bean execute method directly return the data or should I always store the data in an instance variable an then get it using getter methods?
I know this questions are more about J2EE Design Patterns and JavaBeans specification than they are about Web Dynpro but I also have doubts about the rules that the command bean must obey in order to accomplish a successful JavaBean model import in WD.
Some guidance or tips would be highly appreciated.
King RegardsI have the same problem.
Does anyone know the solution?
Thanks
Davide -
Transaction Problem in Session Facade Design Pattern
Hi
Well Sorry for giving wrang title to the topic, coz of which I have not received and reply.
I am using session facade design pattern.
I have Action class calling session facade method "getData" . This method calls "findByPrimaryKey" method in BMP.
Method "getData" has transaction attribute as "RequiresNew" and "findByPrimaryKey" has "Required".
This combination does not assign identity to BMP hence I can not use setter getter method for retriving data(throws nullpointer exception when getter method accessed) I have made sure that I am accessing table and getting data in to BMP but as BMP is not ablle to hoild any identity its not allowing me to use BMP's getter method in session facade.
I have Used Same transaction attribute for create method called by "addNew" method of session facade bean.
Transaction method for "addNew" is "RequiresNew" and for "create" is "Required".
It works fine and gives identity toBMP hense I can use Setter getter method defined in BMP bean.
How can I avoid this and get BMP an identity?
Thanking in Advance,
Chintan.Sorry, how is this related to JSF?
There's an OO/patterns forum out. Consider reposting the question over there with formatted code. -
Observer Design Pattern: Looking for redesign ABAP OO code example
Hello folks,
I am looking for an example for ABAP OO code that has been redesigned by applying the Observer Design Pattern. I would be very interested in both the code before as well as the code after the pattern is being applied.
Thanks in advance and kind regards, AlexObserver can be implemented using the EVENTS.
I had recently implemented the observer at one of my client's place. I had screen with so many ALVs. One ALV was kind of editable and other were just showing the information of the current row as well as some total information. So, initially I started with the Main ALV and SUB(1 and 2) for other ALVs. Now, when I need to refresh my ALVs based on the main ALV data, I had to explicitly update the data of the each Sub ALV. The code was kind of static and requirement was not yet fixed.
Later on we need to add one more ALV on the same screen. It was easy to change the existing method where I was doing the explicit refresh of each ALV. But I thought of using the Events.
I created an event REFRESH_DETAILS for main ALV. so, when data gets changed (which I was catching by DATA_CHANGED event of ALV), I raise the event.
RAISE EVENT REFRESH_DETAILS
exporting new_data = it_Data.
In Sub ALVs, I created the event handler method to handle the event REFRESH_DETAILS of the main ALV.
methods: handle_refresh_details
for event REFRESH_DETAILS of ZCL_MAIN_ALV.
I also had to register the Handler.
SET HANDLER me->handle_refresh_details FOR ALL INSTANCES.
I'll soon write a post on my [ABAP Help blog|http://help-abap.zevolving.com/] with all the details.
Regards,
Naimesh Patel -
Design Patterns, The Decorator
When trying to implement the classic decorator design patterns your decorator executable might look like this:<br><br>
<pre>
METHOD validate.
DATA: Validator TYPE REF TO validation_manager.
CREATE OBJECT:
Validator TYPE validation_manager.
,Validator TYPE validate_format EXPORTING x_validator = Validator
,Validator TYPE validate_values EXPORTING x_validator = Validator
,Validator TYPE validate_relation_input EXPORTING x_validator = Validator
,Validator TYPE validate_relation_database EXPORTING x_validator = Validator.
me->lst_result = validator->validate( me->lst_data ).
WRITE: / 'Processing Validate Activity'.
ENDMETHOD. "validate</pre><br><br>
The validate method ends up in endless resurcion in the memory. The reason is that I'm using the same variable as the resulting instanse and as parameter. It seems like the constructor treats both the result and the parameter as the same field/instanse regardless import parameter such as VALUE/REFERENCE. If I change the method to use an extra field in the method validate like:
<br><br><pre>
METHOD validate.
DATA:
validator TYPE REF TO validation_manager
,recursive TYPE REF TO validation_manager.
CREATE OBJECT validator TYPE validation_manager.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_format
EXPORTING x_validator = recursive.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_values
EXPORTING x_validator = recursive.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_relation_input
EXPORTING x_validator = recursive.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_relation_database
EXPORTING x_validator = recursive .
recursive ?= validator.
me->lst_result = validator->validate( me->lst_data ).
WRITE: / 'Processing Validate Activity'.
ENDMETHOD. "validate</pre><br><br>
Now the decorator engine works, but why does the first implementation not work when the same one executes fine in php, c++, delphi, java and other languages.<br><br>
If you do not know what I'm trying to discuss, look up "Design Patterns - Simply", and jump to the chapter about the decorator design pattern. I'm trying to use this design pattern for a validation manager within my Business Process Engine, which needs to be able to configure what types of validation needed for on specific process (BPMN).<br><br>Hi Matt, Thanks for the formatting..:) I will post the complete program as it's only a prototype program. Trying to get the format under control.
</body>
Report ZDP_DECORATOR_XMP01
REPORT zdp_decorator_xmp01.
parameters: bestimpl TYPE boolean_01 default 0.
TYPES:
BEGIN OF processdata
,name TYPE char30
,street TYPE char30
,zip TYPE char5
,city TYPE char30
,email TYPE char50
,phone TYPE char20
,END OF processdata
,BEGIN OF result
,msgid TYPE msgid
,msgtyp TYPE msgty
,msgno TYPE msgno
,status TYPE char1
,END OF result.
CONSTANTS:
true TYPE boolean_01 VALUE 1
,false TYPE boolean_01 VALUE 0.
CLASS validationmanager DEFINITION
CLASS validation_manager DEFINITION.
PUBLIC SECTION.
METHODS:
validate
IMPORTING
x_data TYPE processdata
RETURNING
value(y_result) TYPE result.
ENDCLASS.
CLASS validationmanager IMPLEMENTATION
CLASS validation_manager IMPLEMENTATION.
METHOD validate.
WRITE: / 'Common validation'.
ENDMETHOD. "validate
ENDCLASS.
CLASS Validate_Decorator DEFINITION
CLASS validate_decorator DEFINITION INHERITING FROM validation_manager ABSTRACT .
PUBLIC SECTION.
DATA: validator TYPE REF TO validation_manager.
ENDCLASS.
CLASS validate_format DEFINITION
CLASS validate_format DEFINITION INHERITING FROM validate_decorator.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING value(x_validator) TYPE REF TO validation_manager
,validate REDEFINITION.
ENDCLASS.
CLASS validate_format IMPLEMENTATION
CLASS validate_format IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor( ).
me->validator = x_validator.
ENDMETHOD. "constructor
METHOD validate.
y_result = validator->validate( x_data ).
IF y_result-status IS INITIAL.
WRITE: / 'Now doing the format checks'.
ENDIF.
ENDMETHOD. "validate
ENDCLASS.
CLASS validate_values DEFINITION
CLASS validate_values DEFINITION INHERITING FROM validate_decorator.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING value(x_validator) TYPE REF TO validation_manager
,validate REDEFINITION.
ENDCLASS.
CLASS validate_values IMPLEMENTATION
CLASS validate_values IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor( ).
me->validator = x_validator.
ENDMETHOD. "constructor
METHOD validate.
y_result = validator->validate( x_data ).
IF y_result-status IS INITIAL.
WRITE: / 'Now doing the values checks'.
ENDIF.
ENDMETHOD. "validate
ENDCLASS.
CLASS validate_relation_input DEFINITION
CLASS validate_relation_input DEFINITION INHERITING FROM validate_decorator.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING value(x_validator) TYPE REF TO validation_manager
,validate REDEFINITION.
ENDCLASS.
CLASS validate_relation_input IMPLEMENTATION
CLASS validate_relation_input IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor( ).
me->validator = x_validator.
ENDMETHOD. "constructor
METHOD validate.
y_result = validator->validate( x_data ).
IF y_result-status IS INITIAL.
WRITE: / 'Now doing the relation input checks'.
ENDIF.
ENDMETHOD. "validate
ENDCLASS.
CLASS validate_relation_database DEFINITION
CLASS validate_relation_database DEFINITION INHERITING FROM validate_decorator.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING value(x_validator) TYPE REF TO validation_manager
,validate REDEFINITION.
ENDCLASS.
CLASS validate_relation_database IMPLEMENTATION
CLASS validate_relation_database IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor( ).
me->validator = x_validator.
ENDMETHOD. "constructor
METHOD validate.
y_result = validator->validate( x_data ).
IF y_result-status IS INITIAL.
WRITE: / 'Now doing the relation database checks'.
ENDIF.
ENDMETHOD. "validate
ENDCLASS.
CLASS process_execution DEFINITION
CLASS process_execution DEFINITION.
PUBLIC SECTION.
METHODS:
startevent
,getdata
,validate
,process
,endevent.
PRIVATE SECTION.
DATA:
lst_data TYPE processdata
,lst_result TYPE result.
ENDCLASS. "process_execution DEFINITION
CLASS process_execution IMPLEMENTATION
CLASS process_execution IMPLEMENTATION.
METHOD startevent.
WRITE: / 'Processing startevent'.
ENDMETHOD. "startevent
METHOD getdata.
me->lst_data-name = 'Hans Andersen'.
me->lst_data-street = 'H.C Andersens Boulevard 112'.
me->lst_data-zip = '1557'.
me->lst_data-city = 'København'.
me->lst_data-email = 'hcATandersen.dk'.
me->lst_data-phone = '0045-31162211'.
WRITE: / 'Processing Get_Data Activity'.
ENDMETHOD. "getdata
METHOD validate.
DATA:
validator TYPE REF TO validation_manager
,recursive TYPE REF TO validation_manager
IF bestimpl = true.
CREATE OBJECT:
validator TYPE validation_manager
,validator TYPE validate_format EXPORTING x_validator = recursive
,validator TYPE validate_values EXPORTING x_validator = recursive
,validator TYPE validate_relation_input EXPORTING x_validator = recursive
,validator TYPE validate_relation_database EXPORTING x_validator = recursive.
ELSE.
CREATE OBJECT validator TYPE validation_manager.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_format
EXPORTING x_validator = recursive.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_values
EXPORTING x_validator = recursive.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_relation_input
EXPORTING x_validator = recursive.
recursive ?= validator.
CREATE OBJECT validator TYPE validate_relation_database
EXPORTING x_validator = recursive .
recursive ?= validator.
ENDIF.
Recursive call of the validate and it's successors
me->lst_result = validator->validate( me->lst_data ).
WRITE: / 'Processing Validate Activity'.
ENDMETHOD. "validate
METHOD process.
WRITE: / 'Processing Process Activity'.
ENDMETHOD. "process
METHOD endevent.
WRITE: / 'Processing endevent'.
ENDMETHOD. "endevent
ENDCLASS.
CLASS mainapp DEFINITION *
CLASS mainapp DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
main.
ENDCLASS.
CLASS mainapp IMPLEMENTATION *
CLASS mainapp IMPLEMENTATION.
METHOD main.
DATA:
p89 TYPE REF TO process_execution.
CREATE OBJECT p89.
p89->startevent( ).
p89->getdata( ).
p89->validate( ).
p89->process( ).
p89->endevent( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
mainapp=>main( ).
Edited by: Matt on Dec 22, 2009 2:03 PM Fixed formatting -
Design Patterns: 'Program to an interface, not an impl.' and Factory Method
Design Patterns: 'Program to an interface, not an implementation' and Factory Method.
Hi All,
I've 4 questions. And 1M thanks for your precious input.
1. OOAD steps:
Requirement-->Use Cases-->Analysis Classes-->Sequence Diagrams-->CRC-->other UML diagrams if needed--> Domain/Business Classes.
If we follow the rule 'Program to an interface, not an implementation',
would that imply NECESSARILY we should have another set of Interface Classes for our Domain Classes? i.e Interface_ClassX for ClassX_Impl.
2. If the point 1 is a MUST because of the rule 'Program to an interface, not an implementation',
ie we should have an Interface classe for every one Domain classe,
would that NECESSARILY imply we should have as many Factory Methods as they are Domain Classes to abstract the creation process?
Interface_ClassX X= Factory.GetClassX() ( return new ClassX_Impl)
Interface_ClassY Y= Factory.GetClassY() ( return new ClassY_Impl)
Interface_ClassZ Z= Factory.GetClassZ() ( return new ClassZ_Impl)
3. On the point 2, the underlying principle used is Factory Methods.
Now on the surface, what are other possible business and/or technical naming for such Factory Methods? I mean should we call it a kind of Business Facade?
4. Is the point 1 and point 2 considered to be the best practices?So the question here is whether we can predict having
more than one possible implementations which required
option c. Is this a dilema? I guess it's hard to
predict the future.Right. Hopefully it's fairly obvious while designing things and
deciding what objects are needed.
Now, if the Presentation Tier, says JSP, needs that
ClassNormal object. Would we still keep that line of
code a.
OR would we introduce an intermediate object to free
JSP from the direct creational aspect using new
keyword like the choice b. that you reject.
The point here is to reduce the direct coupling aspect
between the Presentation Tier and Business Tier. So
what would that intermediate object be?In that case, you have to ask yourself if there is a valid
need for reducing the coupling. If you simply make an intermediate
object, what keeps you from making an intermediate object to your
new intermediate object, ad infinitum.
That intermediate object could be a Facade pattern, or simply
an abstraction. We actually did that here, we began a massive
java project, and we abstracted away from Swing J-classes and created
our own "wrappers" that simply extended all the J-classes and we had
all our programmers develop using our wrappers instead of the Swing
classes. That allowed us to add some custom code, some temporary bug fixes, etc. Some of our classes were nothing more than "EPPasswordField extends JPasswordField" with nothing overridden. It does allow us a place to hook in and adjust or fix things if needed though. -
Design patterns for Dynamic Class Loading
Hi,
I have to develop a program for uni that dynamically loads classes based on names in a text file. All the classes subclass an abstract class with a constructor that takes one argument. This means I can't use the Class.forName(className).newInstance() method of class loading. I have researched some design patterns I could use and have come up with the following 3:
Factory pattern; "Robocode" pattern (not it's real name, but Robocode uses it); and, the "one I made up myself" pattern.
The robocode pattern instantiates a class using the default no-argument constructor then immediately sets all properties that shoud have been provided in the constructor:
Object o = Class.forName(myClass).newInstance();
o.setProperty(property);Personally I think this is ugly and a cheap fix instead of doing it properly.
My own pattern finds the constructor that takes the arguments I need then calls it to create the object:
Class c = Class.forName(myClass);
Constructor cons = c.getConstructor(new Class[]{Class.forName("java.lang.String")});
Object o = cons.newInstance(new Object[]{"hello"});What's the best to use? Are there any other patterns I should consider?My own pattern finds the constructor that takes the
arguments I need then calls it to create the object:
Class c = Class.forName(myClass);
Constructor cons = c.getConstructor(new
Class[]{Class.forName("java.lang.String")});
Object o = cons.newInstance(new Object[]{"hello"});
I have followed this basic 'pattern' several times though I would use
Constructor cons = c.getConstructor(new Class[]{String.class});
It works great. -
Fixing Size of Column in Cross Tab
Plz tell me how to fix Size of column.in my case the data in column is not fixed so the output in PDF shows different size of Columns.I want want to fix them.
plz help
thanks in advanceYou can call (on your table) getColumnModel().getColumn(i).setWidth(), but that information is lost once you call tableStructureChanged in your table model. To solve this problem I use my own TableModel, which sets the with of the columns every time they are created:
public class MColumnModel extends DefaultTableColumnModel {
private int [] widths;
public MColumnModel(int[] widths) {
super();
this.widths = widths;
public TableColumn getColumn(int index) {
TableColumn column = super.getColumn(index);
if (column == null)
return column;
column.setPreferredWidth(metaWidths [index]);
return column;
}Be sure to call setColumnModel before you call setModel on your table.
The widths are relative. If you want to set absolute widths, you have to call
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);Regards
Der Hinterwaeldler -
Regarding which design pattern to use for this scenario???
hi guys
I am working on a J2EE application where I need to do translations for 3 different scenarios. It is basically a conversion from service order objects to invoices.
First from a service order object to an invoice.
Second a conversion from a transaction table.
Third a conversion from a remote system.
Finally the product is an invoice..
What design pattern can i use ....is strategy pattern a good idea??
Thanks
JHi,
I think your problem is in result state. You can you sequencial block but for approve or reject you need to set target for each result state. Here I am providing a link. I think you will get your solution here please go through it.
http://help.sap.com/saphelp_nw2004s/helpdata/en/44/429bbd709914bce10000000a155369/frameset.htm
if you have any query please let me know.
Thanks
Chandan -
[disc]Design pattern - immutable objects.
I`m working more often with immutable object because it doesn`t cost as much work to keep object consistent. But sometimes an object has to be build or a reference to his child objects has to be set.
eg
class A{
private ArrayList bList = new ArrayList();
public A(){}
public void addB(B b){
bList.add(b);
class B{
private A a;
public B(A a){
this.a = a;
}It`s now more complicated to make a immutable version of A.
My question is how this problem could be solved. One solution is to add an immutable flag that could be set to true if the last B is added. But this couldn`t be checked compile time.
Maybe there is a design pattern for this problem.
I would like to discuss about this problem, so every thought is welcome.I have an Immutable Collection wrapper class that I use when I want to have a Collection be read-only.
If you look at the JavaDoc for AbstractCollection you'll see that the add and remove methods throw UnsuportedOperationException.
So all you have to do is implement the iterator() and size() methods. i.e.
public class ImmutableCollection extends AbstractCollection {
private Collection collection;
* only constructor
public ImmutableCollection(Collection collection) {
this.collection = collection;
* returns the size of the collection
public int size() {
return collection.size();
* returns a non-modifiable iterator over the elements of the collection
public Iterator iterator() {
return new Iterator() {
Iterator iterator = collection.iterator();
public boolean hasNext() {
return iterator.hasNext();
public Object next() {
return iterator.next();
public void remove() {
throw new UnsupportedOperationException();
}
Maybe you are looking for
-
>I am looking at the c and I can find much for in car devices like ?all in one holders?. Belkin to a fantastic range for the ipod but yet im finding it hard to get something that is designed for any creative mp3 player! If anyone could let me know if
-
Query faild against database that is opened in read only mode
ORA-16000: database open for read-only access Hi , I am quering against a database that been opened in read only mode (10g version) SQL> select controlfile_type,open_mode,database_role from v$database; CONTROLFILE_TYPE OPEN_MODE DATABASE_ROLE STANDBY
-
Hello there, My question is related to formatting in the markup (xml). I need/want to have specific value for 'leading' inside the List element. As far as I understand and see in my text, 'leading' inside List element inherits paragraphSpaceAfter val
-
Check Maintain compatibility Checkbox in 64 bit word 2013
Hello, I am creating a plugin for Word in VB.net and i need to Check the checkbox of "maintain compatibility with previous version" when my plugin set up installs. So Is there any registry or any code to check that checkbox permanently. Plzzzzzzzzzzz
-
Pfile creation in cluster database
Hi, I am trying to create a pfile from spfile, here is the command i used create pfile='D:\oracle\database\inittest.ora' from spfile='e:\cdd\spfilecdd.ora'; i logged in as sys and issued the above command but dont see the file in the database directo