Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

sql - Python: How can I merge these 2 overloaded constructors into 1 constructor -


i have class called portfolio & right have 2 constructors (although discovered u cant overload functions in python) so have merge these 2 constructors.

i experienced python programmer merging 2 constructors pretty contradictory doing head in! :p

the first constructor:
+ purpose create .db file & initialise class variables
- initialises class member variables
- checks whether file path&name db_path exists: if exit coz dont want overwrite existing database return none
- create database (sql database) & set necessary tables
- import portfolio data (date created, etc)

the 2nd constructor:
+ purpose import stock data existing sql database file & initialise variables
- initialises class member variables
- checks whether file path&name db_path exists: if not exit coz dont want overwrite existing database return none
- call function import stocks database
- import portfolio data (date created, etc)

how can merge these 2 constructors, ugh, why doesn't python allow overloading

class portfolio: """ portfolio class implementation """  # class variables:  # self.db_path # self.app_parent # self.tracking_stocks # self.registered_stocks # self.total_purchase_exp # self.ytd_roi # self.cash_reserve   # class functions:  def __init__( self, _app_parent, _db_path, stock_list ):     """ constructor: """      self.db_path            = _db_path     self.app_parent         = _app_parent     self.tracking_stocks    = []     self.registered_stocks  = []     self.total_purchase_exp = 0     self.ytd_roi            = 0     self.cash_reserve       = 500      if database_exists( self.db_path ):         return none      self.create_database()     self.import_portfolio_data()      stock_data in stock_list:          self.add_stock( stock_data )   def __init__( self, _app_parent, _db_path ):     """ constructor: """      self.db_path            = _db_path     self.app_parent         = _app_parent     self.tracking_stocks    = []     self.registered_stocks  = []     self.total_purchase_exp = 0     self.ytd_roi            = 0     self.cash_reserve       = 500      if not self.database_exists( self.db_path ):         return none      self.import_portfolio_data()     self.import_stocks() 

why have happen in constructors?

you construct object, call separate methods on for importing stock lists, or creating database.

wrapping in builder pattern may suit existing design.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -