d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Multi-dimensional Maps Vs Inner Class > Question
Prev12
Add Reply New Topic New Poll
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Jun 30 2016 01:35pm
It would actually be more like

Code
class Event {

List <Location> locations; //or a list, if you only ever have a few. Also assumes Id is a valid type
//some other properties

}

class Location {

List <PointOfInterest> pointsOfInterest;
//some other properties. Probably geo coordinates or an address

}

class PointOfInterest {

//some properties

}
Member
Posts: 23,256
Joined: Jun 30 2009
Gold: 1.03
Jun 30 2016 04:11pm
Quote (Minkomonster @ Jun 30 2016 03:35pm)
It would actually be more like

Code
class Event {

List <Location> locations; //or a list, if you only ever have a few. Also assumes Id is a valid type
//some other properties

}

class Location {

List <PointOfInterest> pointsOfInterest;
//some other properties. Probably geo coordinates or an address

}

class PointOfInterest {

//some properties

}



This is the correct format. There should be no reason the map is in the event class. It is not the class' responsibility to hold a map. You should create another class designed to the requirements of the map.
Member
Posts: 1,849
Joined: May 31 2008
Gold: 2,571.50
Jun 30 2016 06:23pm
So I revamped my page/classes to not do the badness of multi-dimensional classes.

I found out that the fix for me was to redo/optimize my queries to avoid the need for a nested map. Now I only have something like Map<Id, List<sObject>>();

There seems to be a good way to do a outer join in my soql to eliminate a need for a lot of the maps I've been creating in the code I've been writing. Overall this was a very helpful thread for me as the "outcry" of it being wrong made me re-evaluate my methodology and to look for better ways to do what I'm trying to do.

Thanks for all the info/feedback guys.

This post was edited by Noobtard on Jun 30 2016 06:23pm
Member
Posts: 23,256
Joined: Jun 30 2009
Gold: 1.03
Jun 30 2016 06:29pm
Quote (Noobtard @ Jun 30 2016 08:23pm)
So I revamped my page/classes to not do the badness of multi-dimensional classes.

I found out that the fix for me was to redo/optimize my queries to avoid the need for a nested map. Now I only have something like Map<Id, List<sObject>>();

There seems to be a good way to do a outer join in my soql to eliminate a need for a lot of the maps I've been creating in the code I've been writing. Overall this was a very helpful thread for me as the "outcry" of it being wrong made me re-evaluate my methodology and to look for better ways to do what I'm trying to do.

Thanks for all the info/feedback guys.


I thought this was a simple project. If you are actually accessing a database then I suggest you use the hibernate or Spring JDBC framework. Hibernate is techically better and more widely used but Spring is much easier to learn than hibernate. Good luck.

Edit: The framework you use should use depends on the type of database you are using.

This post was edited by umeshieee on Jun 30 2016 06:30pm
Member
Posts: 1,849
Joined: May 31 2008
Gold: 2,571.50
Jun 30 2016 06:56pm
Quote (umeshieee @ Jun 30 2016 07:29pm)
I thought this was a simple project. If you are actually accessing a database then I suggest you use the hibernate or Spring JDBC framework. Hibernate is techically better and more widely used but Spring is much easier to learn than hibernate. Good luck.

Edit: The framework you use should use depends on the type of database you are using.


So I'm working on the Salesforce framework as I work for a company that develops salesforce applications.

I've used hibernate in the past for school projects.

The main issue I've been having is although the high level things I learned in school stay relevant, the way I do them seems different. Like the main reason I gravitated towards multi-dimensional map is so that I can easily loop through locations on my visualforce page and display given information of related objects based on the current locationId. Now that I've learned how to do the outer joins and talked with a team member on better ways and using what was posted here hunted for salesforce 'equivalent' practices. There definitely is room for self-improvement....

Learning the outer join has already saved me.... X queries and quite a bit of development time AND[ most definitely has made what I'm trying to do cleaner/more maintainable.

This post was edited by Noobtard on Jun 30 2016 06:57pm
Member
Posts: 7,324
Joined: Dec 22 2002
Gold: 1,261.00
Jul 7 2016 03:54pm
Quote (Minkomonster @ Jun 30 2016 12:35pm)
It would actually be more like

Quote (umeshieee @ Jun 30 2016 03:11pm)
This is the correct format. There should be no reason the map is in the event class. It is not the class' responsibility to hold a map. You should create another class designed to the requirements of the map.


Why wouldn't a class hold a map of something? It's completely valid for Event to have a map of Location, if his particular problem calls for a map. It's impossible to say whether the correct implementation is a List or a Map without knowing more about what he's trying to do. If he has a large number of locations and wants to optimize their lookup, a List would be a poor choice.
Member
Posts: 7,324
Joined: Dec 22 2002
Gold: 1,261.00
Jul 7 2016 04:06pm
Quote (Noobtard @ Jun 30 2016 05:56pm)
So I'm working on the Salesforce framework as I work for a company that develops salesforce applications.

I've used hibernate in the past for school projects.

The main issue I've been having is although the high level things I learned in school stay relevant, the way I do them seems different. Like the main reason I gravitated towards multi-dimensional map is so that I can easily loop through locations on my visualforce page and display given information of related objects based on the current locationId. Now that I've learned how to do the outer joins and talked with a team member on better ways and using what was posted here hunted for salesforce 'equivalent' practices. There definitely is room for self-improvement....

Learning the outer join has already saved me.... X queries and quite a bit of development time AND[ most definitely has made what I'm trying to do cleaner/more maintainable.


Cool, I've been working on a project that integrates with Salesforce for a bit over a year now. Although personally I prefer MS Dynamics CRM. Salesforce is really haphazard about its design, as it evolved over time and has some lots of really odd (and sometimes frustrating) limitations and quirks. Dynamics was designed from the ground up to be fairly complex and feels way more polished and better thought out.
Member
Posts: 3,939
Joined: Feb 1 2013
Gold: 2,749.09
Warn: 20%
Jul 16 2016 02:34pm
retract bid

This post was edited by boxboxbox on Jul 16 2016 02:34pm
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll