SOLID and ScriptableObject ?

Joined
Apr 19, 2020
Messages
7
Programming Experience
1-3
[Unity]
Hi, everybody. I try to bring my knowledge to the ideal, in particular the principles of SOLID.

Is it correct if the data class (which contains an abstraction but NOT an implementation) will have methods GetAvailableItems... that is, methods that return data of this class after the necessary processing. The class state does not change.

Or by SOLID and OOP, the class /structure data should not have an implementation at all (any methods), but only fields and properties.

Example:
C#:
 public class Content : ScriptableObject
    {

        private int _example...;
        private int _example..;
        private int _example.;

        private int[] _items;

        public int[] GetAvailableItems()
        {

            int[] list = new int[] {};
            //....
            return list;
           
        }

    }

Is there a violation of SOLID and OOP ?
 
That depends. Your example code doesn't demonstrate anything to do with abstraction. The examples I will link below do.

If you have a class of abstract vehicles. You can have an Abstract class vehicle, where the used logic works for every vehicle. So you can just pass car and van as a vehicle because the vehicle class is an abstraction of both types of car and van. If one of your objects was accelerator or break, then these are parts of your types car and van which can exist in every vehicle. See some examples here : C# | Abstract Classes - GeeksforGeeks
 

Latest posts

Back
Top Bottom