Virtual-Assistant icon indicating copy to clipboard operation
Virtual-Assistant copied to clipboard

Code structure

Open pavan-pan opened this issue 6 years ago • 9 comments

Hello all,

Is there any special reason why the code is organised by including the .c files. According to my knowledge, implementation of a function in .c file and prototype in .h file creates loose coupling among modules. I guess there is a reason why the code in this project is structured this way. I just want to know your views.

Regards, PP

pavan-pan avatar Feb 21 '19 15:02 pavan-pan

@pavan-pan There's no specific reason as such. it's just that previously it was a single main.c file consisting of all the functionalities. Then later @igo4Jesus in #31 split it in different files for better code readability. If you think something else is better. Please suggest.

ritwik12 avatar Feb 21 '19 16:02 ritwik12

@riya-17 I would like your reviews here

ritwik12 avatar Feb 21 '19 16:02 ritwik12

My idea is to divide the entire program into modules consisting .c and .h files. So every module is loosely coupled. Instead of adding .c files, .h files are included instead. When the code grows bigger, its easier when everything is organized in modules.

pavan-pan avatar Feb 21 '19 18:02 pavan-pan

@ritwik12 I find the idea of @pavan-pan better. It will increase the understanding of code as well. What do you think @ritwik12 ?

riya-17 avatar Feb 21 '19 19:02 riya-17

@pawan-pan sure, please go for it and send a PR

ritwik12 avatar Feb 22 '19 11:02 ritwik12

I have been working on reorganizing the code and using a CMake system to build it. Once I have the system running, I will need to re-add some features that were added later (email support etc.). I will try to send a PR by next week.

virajmalia-zz avatar Jul 21 '19 06:07 virajmalia-zz

@virajmalia That's great, will wait for your PR, Thanks !!

ritwik12 avatar Jul 21 '19 07:07 ritwik12

I agree with refactoring/restructuring in this way, where pieces of logic are extracted into separate src files (.c) but only header files (.h) are included. Including src files is commonly considered bad practice, while the approach proposed here supports modular design, which is better and a lot easier to maintain, scale and test/debug.

I have started working on refactoring the code in this way.

RoyMattar avatar May 23 '20 17:05 RoyMattar

@RoyMattar Thanks for taking interest!!

ritwik12 avatar May 23 '20 19:05 ritwik12