[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 583: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 639: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
Gephi forums •Question on the use of Lookup
Page 1 of 1

Question on the use of Lookup

Posted: 11 Jul 2016 15:43
by littleBobbyTables
I wasn't quite sure where to put this question, so I'm putting it here. I am trying to figure out the point of using Lookup in the Gephi toolkit to create things like the ProjectController and the GraphModel. I can't find a lot of documentation on how Lookup is used, and I'm trying to determine if it could relate to a small problem my program is having. I would greatly appreciate any help on figuring out why this is used, and if it's not necessary what could be used in its place. Thanks!

Re: Question on the use of Lookup

Posted: 12 Aug 2016 13:40
by Alarmwolf
Hi, may be my comment will be too late, but anyway) Lookup is one of the things that may really confuse you at the beginning of Gephi (and Netbeans Platform).
'Lookup' is one of mechanisms of Netbeans Platform, that helps modules to get their dependencies. Instead of creating some objects (like ProjectController) by yourself (with 'new ...') you just saying 'Give me ready instance of ProjectController' in code like:
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);

The best and short description of this tool I saw in the next cheatsheet:
https://dzone.com/refcardz/netbeans-platform-70

This mechanism saves developer of new modules from handy creating or long searching of heavy objects, because logic of their lifecycle can be very complex, but it isn't interesting for developer, he just needs object with its api :) For example, may be it's wrong to have 2 ProjectControllers in application - Lookup will find existed instance and give it to us.

This pattern is one of implementations of 'Inversion of control' design principle.

Please correct me if I said something wrong)