Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common vs Core - difference

Assume we have a couple of libs. What is the difference between Core and Common library? How should they be recognized and do we organize the responsibilites of both?

+Common
  -Class1
+Core
  -Class2
+Lib1 has : Common
+Lib2 has : Core, Common

Should Common be truely common (i.e. all libs use it)? Or is Common only for those who need it?

What is good practice when refactoring / creating a project?

I don't really understand the difference between Core and Common.

like image 312
Puchacz Avatar asked Apr 19 '15 20:04

Puchacz


Video Answer


1 Answers

I think this depends a lot on your particular application. In a single centralized app, I do think there might be a little overlap between the Core and Common folders. But the most important thing is that it makes sense for your app. Don't feel that you need to have those folders just because you've seen it in other apps...

For me, having a Core and a Common folders makes a lot of sense in some scenarios - e.g. a web app with an API and a client. You may have your Core folder in the API side, where the core execution (the business logic) takes place, and then have a Common folder with some things you need in both the API and the client sides - e.g., Http requests validation or a Json converter.

Anyway, it may make sense to have a Core and a Common folder in other kinds of apps.
For example, the Core folder would contain those classes that are central for your app - the vast majority of business model classes would be there.
In the Common folder, on the other hand, you can have some other classes that are shared, but not central - e.g., a Logger or a MessageSender could be there...

As for your little draft of code structure, I think that your Core package is the one to be revised - why Lib1 doesn't use Core? If something is core, generally it's because everything else needs it in order to run. If you do not have code that is conceptually central, maybe you can remove your Core package and keep only Common?

As for your other question - I do not think the Common stuff must be shared by all other packages, but just with 2 or more packages sharing something, that can be considered common.

like image 75
MikO Avatar answered Oct 18 '22 02:10

MikO