It is currently 29 Oct 2025, 07:15
   
Text Size

Some code examples

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

Some code examples

Postby Max mtg » 13 Nov 2012, 20:51

I don't know whose code that is but I am definetelly quite unhappy to find such masterpieces in our project.

Code: Select all
        // Show or hide the set unlocking button
        if (qCtrl.getFormatNumberUnlockable() > 0) {
            view0.getBtnUnlock().setVisible(true);
        } else {
            view0.getBtnUnlock().setVisible(false);
        }
why don't just write
Code: Select all
view0.getBtnUnlock().setVisible(qCtrl.getFormatNumberUnlockable() > 0)
?
Last edited by Max mtg on 13 Nov 2012, 21:43, edited 1 time in total.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Some code examples

Postby Max mtg » 13 Nov 2012, 20:57

How do we get sorted list of all magic edtions? I have seen a solution!
Code: Select all
TreeMap<Integer, CardEdition> sortedMap = new TreeMap<Integer, CardEdition>();
        for (CardEdition ce : Singletons.getModel().getEditions()) {
           sortedMap.put(new Integer(ce.getIndex()), ce);
        }

        List<CardEdition> sortedEditions = new ArrayList<CardEdition>(sortedMap.values());
meanwhile CardEdition implements Comparable and you can get sorted list in 2 steps:
Code: Select all
List<CardEdition> editions = Lists.newArrayList(Singletons.getModel().getEditions());
Collections.sort(editions);
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 8 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 8 users online :: 0 registered, 0 hidden and 8 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 8 guests

Login Form