SOLID is an acronym for a set of five software development principles, which if followed, are intended to help developers create flexible and clean code. The five principles are:
The Single Responsibility Principle — Classes should have a single responsibility and thus only a single reason to change.
You do not have permission to view the full content of this post.Log in or register now. — Classes and other entities should be open for extension but closed for modification.
You do not have permission to view the full content of this post.Log in or register now.— Objects should be replaceable by their subtypes.
You do not have permission to view the full content of this post.Log in or register now. — Interfaces should be client specific rather than general.
You do not have permission to view the full content of this post.Log in or register now. — Depend on abstractions rather than concretions.
See You do not have permission to view the full content of this post.Log in or register now.
I wanna put emphasis on SRP (Single Responsibility Principle) in relation to your question. The second form allows you to encapsulate common logic that belongs to your custom MyThread class. But that's really a superficial response. It's like asking is it better to use a screwdriver or knife for sticking holes?
Kung gusto mong organized and hindi masyadong magulo sa index mo pwede mong iseparate class. Optional lang naman yun since student ka pa lang pero sa industry advisable ang separate class para mas madaling masundan ng ibang devs.
I wanna put emphasis on SRP (Single Responsibility Principle) in relation to your question. The second form allows you to encapsulate common logic that belongs to your custom MyThread class. But that's really a superficial response. It's like asking is it better to use a screwdriver or knife for sticking holes?
Kung gusto mong organized and hindi masyadong magulo sa index mo pwede mong iseparate class. Optional lang naman yun since student ka pa lang pero sa industry advisable ang separate class para mas madaling masundan ng ibang devs.
The upper syntax uses anonymous class while the other one is a separate class that extends the Thread Class. You use the upper one if you only need those Thread methods and only concern about it's functionalities. Use the other one if you have some stuff while it needs to incorporate the Thread methods, hence, your class needs to override it's methods. You can simulate this by creating your own Interface then implement its method by using both of these techniques.