The Artima Developer Community
Sponsored Link

Java Answers Forum
Worst Code ever! Restrictive Swing Frameworks

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Worst Code ever! Restrictive Swing Frameworks Posted: Nov 8, 2007 7:33 AM
Reply to this message Reply
Advertisement
Haven't posted in a long time but I had to share this.

A framework called SpringRich, short of the fact that they have things like ComboBoxModels set as Inner classes, I came across this a class called TableUtils.

Has a method called: "attachSorter(JTable)"

One would think it would it would attach some sort of Sorter from the name, but on code investigation:


public static JTable attachSorter(JTable table) {
TableModel tableModel = table.getModel();
ShuttleSortableTableModel sortedModel = new ShuttleSortableTableModel(tableModel);
table.setAutoCreateColumnsFromModel(true);
table.setModel(sortedModel);
TableSortIndicator sortIndicator = new TableSortIndicator(table);
new SortTableCommand(table, sortIndicator.getColumnSortList());
return table;
}


WTF? I kept losing my JComboBox editor in my builder, couldn't for the life of me figure it out until I examined this code.

Lets see...

We have a static method that instead of simply adding functionality to your JTable, it strips it of some by setting its own ridiculous table model which fries your
CellEditor.

Static methods should not reassign Objects on whatever you pass in unless explicitly mentioned.

I mean what the hell!!

Topic: Worst Code ever!  Restrictive Swing Frameworks Previous Topic   Next Topic Topic: java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use