Refactor Functions/Objects to Properly Segregate Functionality #14

Closed
opened 2019-11-21 13:26:21 +00:00 by cmccabe · 5 comments
Owner

Initially, not all functionality was properly segregated across functions, leading to some problems in program flow and preventing some ideal types of program flow. For example, view_thread() and view_category_contents() overlap in an unnatural way.

Initially, not all functionality was properly segregated across functions, leading to some problems in program flow and preventing some ideal types of program flow. For example, view_thread() and view_category_contents() overlap in an unnatural way.
cmccabe added the
future release
label 2019-11-21 13:26:21 +00:00
sloum changed title from Refactor Functions/Objects to Prioerly Segregate Functionality to Refactor Functions/Objects to Properly Segregate Functionality 2019-11-23 18:47:32 +00:00
Collaborator

A lot of functions print information, take in input, and then call other functions. It might be a better model to return functions to caller. So, for example view_category_contents() could graceful_exit(), it could print_categories(), and it could view_thread(). Rather than calling these things, we could return them to a controller function that would handle routing. This would also allow us to return errors easily and handle them.

In order to loop through taking in what post number within a category in view_category_contents() we could validate the input. If the input was invalid we could print a message and then return view_category_contents() itself, so that it would be run again.

Just an idea. There are lots of ways to architect this program and I definitely dont want to step on anyone's toes.

A lot of functions print information, take in input, and then call other functions. It might be a better model to return functions to caller. So, for example `view_category_contents()` could `graceful_exit()`, it could `print_categories()`, and it could `view_thread()`. Rather than calling these things, we could return them to a controller function that would handle routing. This would also allow us to return errors easily and handle them. In order to loop through taking in what post number within a category in `view_category_contents()` we could validate the input. If the input was invalid we could print a message and then return `view_category_contents()` itself, so that it would be run again. Just an idea. There are lots of ways to architect this program and I definitely dont want to step on anyone's toes.
Author
Owner

sloum, those sound like good ideas to me!

sloum, those sound like good ideas to me!
Collaborator

This likely ties in to #17 as well.

This likely ties in to #17 as well.
Collaborator

@cmccabe I think the main purpose of this has now been completed. Menu controls, data queries and views are mostly segregated. Can we close this off?

@cmccabe I think the main purpose of this has now been completed. Menu controls, data queries and views are mostly segregated. Can we close this off?
Author
Owner

Yup!

Yup!
Sign in to join this conversation.
No description provided.