DEV Community

Qu-Ack
Qu-Ack

Posted on

TO-DO-LIST 10

_The Epic Cyberpunk plays_ The Basic architecture is done. We have a TaskModule that takes care of all the function that a task should be able to do such as add task , remove task , change it's priority , render the task, changeDate. This is only the basic structure of our app and we will build upon this.

const Task = (name , desc) => {
    const date = new Date();
    const priority = "boring"; 
    const Name = name;
    const Desc = desc;  


    return {date , priority, Name, Desc}
}

const TaskModule = (function() {
    const Tasks = []

    function render() {
        console.log(Tasks)
    }

    function addTask(task) {
        Tasks.push(task);
        render()

    }

    function removeTask(index) {
        Tasks.splice(index, 1);
        render()
    }

    function changePriority(value , task) {
        task.priority = value;
        render()
    }

    function changeDate(dateval , task) {
        task.date = dateval
        render()
    }

    return {Tasks , addTask , removeTask, changePriority , changeDate}
})()

Enter fullscreen mode Exit fullscreen mode

I know there there are OOP principles that are being violated mainly the single responsibility principle(I have no idea if it is being violated or not !!!) But In my defense this app's scale is not big.
Feel free to give me suggestions on my shit code _Epic Cyber Punk Continues_

Top comments (0)