d3an / finviz

Go API for Finviz
https://github.com/d3an/finviz/wiki
MIT License
20 stars 3 forks source link

Restructure code using more OOP #54

Closed d3an closed 4 years ago

d3an commented 4 years ago

Restructure the existing codebase to support more inherited methods/classes. This extends into supporting other FinViz apps such as News.

Create a partially abstract base class View and interface ViewInterface:

type View struct {}

type ViewInterface interface {
    GenerateURL() string
    Scrape(document *goquery.Document) ([][]string, error)
}

Each app should have a derived object that inherits the predefined interface methods, such as for News:

type NewsView struct {
    finviz.View
}

Going deeper, an app should derive its actual views from the app view base class, ex:

type SourceNewsView struct {
    NewsView
}

This restructuring should help greatly with view URL generation as derived objects can call parent methods, thus generating the URL in a step by step basis: ('https://finviz.com' OR 'https://elite.finviz.com') + '/news.ashx' + '?v=2'.

Additionally, this restructuring will help clean up the file structure of the codebase and make it more presentable and less daunting on GitHub.