class-design

why is java.lang.Throwable a class?

寵の児 提交于 2019-12-02 17:27:00
In java adjectives ending in -able are interfaces Serializable , Comparable etc... So why is Throwable a class? Wouldn't exception handling be easier if Throwable were an interface? (Edit: e.g. Exception classes don't need to extend Exception/RuntimeException.) Obviously, changing it now is out the question. But could it be made abstract? Wouldn't that avoid the bad practice of throw new Throwable() ; So why is Throwable a class? I can think of two reasons: Exceptions have state. In particular, message, cause, and stack trace. It is easier for the JVM to implement efficient catch blocks. Class

PHP class inheritance depth

放肆的年华 提交于 2019-12-02 09:25:06
I'm trying to work out exactly how deep inheritance goes. For example if I start with class A Class B extends class A Class C extends class B Class D extends class C Class E extends class D Class F extends class E Class G extends class F most of the lower levels are abstract classes with methods filled with code and abstract methods. its a rather large and complex structure. (doing my head in) Will Class G still be able to access Class A methods and parameters, as well as still have access to the abstract methods from Class A ? I'm asking because I have been having trouble with eclipse not

Should a class have the same name as the namespace?

匆匆过客 提交于 2019-12-01 17:53:34
I'm designing a namespace to hold a set of classes that will handle user related tasks for a several different applications. (Log-in, authenticate etc) The problem is the namespace will be called Fusion.User but then it requires a class in that namespace that makes sense to call User . Should you have a class with the same name as the namespace? Or am I taking the wrong approach here? Having class named in the same way as the name space (package) may lead to a thought that class is central to the package. But if I get it correctly User is just a data object in your case. As far as I see you

Serializing Data Transfer Objects in .NET

南笙酒味 提交于 2019-12-01 17:04:08
问题 I have a set of data transfer objects (e.g. a lot of reqest, response message classes, like MainRequest, MainResponse, ShutDownRequest, ShutDownResponse) Where new classes keep coming as the project evolves . These classes must be (de)serialized from and to various XML formats with different public XSDs . New XML formats come as the project evolves too. My question here is how I would design my classes and interfaces around these two requirement , especially where I should put the actual (de

Serializing Data Transfer Objects in .NET

佐手、 提交于 2019-12-01 17:00:16
I have a set of data transfer objects (e.g. a lot of reqest, response message classes, like MainRequest, MainResponse, ShutDownRequest, ShutDownResponse) Where new classes keep coming as the project evolves . These classes must be (de)serialized from and to various XML formats with different public XSDs . New XML formats come as the project evolves too. My question here is how I would design my classes and interfaces around these two requirement , especially where I should put the actual (de)serilization logic. Should I write a static service that can take the various DTO instances an knows

Why is ASP.NET Core's Startup class not an interface or abstract class?

家住魔仙堡 提交于 2019-12-01 16:45:50
This is in regards to the design principals behind the Startup class explained here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/startup?view=aspnetcore-2.1 I understand that the class needs to include methods like ConfigureServices or Configure . Why CreateDefaultBuilder(args).UseStartup<Startup>() does not mandate any base class or interface for better readability? With this design approach, someone must read the documentation and know about the magic method names like ConfigureServices or Configure . If this is part of a new class design mindset, then where can I read more

Why is ASP.NET Core's Startup class not an interface or abstract class?

江枫思渺然 提交于 2019-12-01 15:34:34
问题 This is in regards to the design principals behind the Startup class explained here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/startup?view=aspnetcore-2.1 I understand that the class needs to include methods like ConfigureServices or Configure . Why CreateDefaultBuilder(args).UseStartup<Startup>() does not mandate any base class or interface for better readability? With this design approach, someone must read the documentation and know about the magic method names like

UML Class Relationships

人盡茶涼 提交于 2019-12-01 09:11:08
I would like to confirm whether I am on the right track when identifying common UML class relationships. For example, is the relationship between: 1 a stackoverflow member and his/her stackoverflow user account categorized as a composition relationship or an aggregation relationship? At first I thought it was an association because this member "has a" account. However on second thought, I am thinking its composition because each "part" (user account) belongs to only one whole (user) at a time, meaning for as long as I am logged into stackoverflow, I have to use this one and only account until

Core Data entity inheritance --> limitations?

耗尽温柔 提交于 2019-12-01 04:37:51
I thought I'll post this to the community. I am using coredata, and have two entities. Both entities have a hierarchical relationship. I am noticing quite a lot of duplicated functionality now, and am wondering if I should re-structure to have a base Entity which is abstract (HierarchicalObject), and make my entities inherit from them. So the question is are there some limitations of this inheritance that I should take into account? Reading some of the posts out there, I see a few trade-offs, let me know if my assumptions are correct. (Good) clean up structure, keep the HierarchicalObject

UML class diagram: how to model relations about calling a method or starting an activity or service

橙三吉。 提交于 2019-12-01 02:43:50
问题 I'm creating my first Android app. I have avoided to label associations with user or system interactions (e.g. I have labeled starts instead startsWhenClick ; I have labeled starts instead startsWhenDetection ). However, after reading this, I'm considering to change the starts associations by << create >> dependencies. I'm confused! The app works as follow. When the app starts, LauncherActivity will call the methods of BaseActivity to start the activity marked in SettingsActivity (it could be