Featured Post

Management Decision Model and Financial Management

Question: Legitimize the job of money related administration in the event of various undertakings and various circumstances? Answer: ...

Sunday, March 22, 2020

John Locke Theory Of Property Essays - Libertarian Theory, Property

John Locke Theory Of Property Perhaps one of, if not the, most historically influential political thinkers of the western world was John Locke. John Locke, the man who initiated what is now known as British Empiricism, is also considered highly influential in establishing grounds, theoretically at least, for the constitution of the United States of America. The basis for understanding Locke is that he sees all people as having natural God given rights. As Gods creations, this denotes a certain equality, at least in an abstract sense. This religious back drop acts as a the foundation for all of Lockes theories, including his theories of individuality, private property, and the state. The reader will be shown how and why people have a natural right to property and the impact this has on the sovereign, as well as the extent of this impact. Locke was a micro based ideologist. He believed that humans were autonomous individuals who, although lived in a social setting, could not be articulated as a herd or social animal. Locke believed person to stand for, ... a thinking, intelligent being, that has reason and reflection, and can consider itself as itself, the same thinking thing in different times and places, which it only does by that consciousness which is inseparable from thinking. This ability to reflect, think, and reason intelligibly is one of the many gifts from God and is that gift which separates us from the realm of the beast. The ability to reason and reflect, although universal, acts as an explanation for individuality. All reason and reflection is based on personal experience and reference. Personal experience must be completely individual as no one can experience anything quite the same as another. This leads to determining why Locke theorized that all humans, speaking patriarchially with respect to the time why all men, have a natural right to property. Every man is a creation of Gods, and as such is endowed with certain individual abilities and characteristics as gifts from God. Not being able to know Gods exact wishes for man, Locke believed that all men have an obligation to develop and caress these gifts. In essence, each man was in charge of his own body and what was done with his body. Of course, for Locke, each man would do the reasonable thing and develop his natural skills and potentials to the best of his abilities, in the service of God. The belief in God given abilities and the obligations that follow are not totally deterministic. Man, endowed with reason, could choose not to develop these abilities. Having the ability to choose the development of his potential, each man is responsible for that potential and consequently is responsible for his own body. The development, or lack therein, is a consequence of individual motivation and is manifested through labor. In keeping with the theory of ones body is ones own, a mans property can be explained in terms of the quantifying forces of his labors. Physical labor or exercisation of his mind, to produce fruits for this persons labor, is then his own property. Locke believed that one did not need the consent of a sovereign, as far as property was concerned, because it is the melding of labor and nature that makes anything owned. Yolton articulates this when he states, (b)y mixing my work, my energy with some object, (nature), I particulise that object, its commonness becomes particular Locke believed that as long as there was plenty for others, consent was pointless, irrelevant and would merely be an overzealous exercision of power. Pointless because as long as there was more for others in the common store, one was not infringing on anothers natural rights. Irrelevant because property production or the use of labor was completely individualistic and one should not be able to control anothers labo r as it is an infringement on their natural rights. There are however limits, as far as property and labor are concerned. One limit is that of non destruction. God did not create anything for man to destroy. The amount produced by any man should be kept in check by his level of destruction. For example, there is a big difference between the cutting of

Friday, March 6, 2020

Multithreaded Delphi Database Queries With dbGo (ADO)

Multithreaded Delphi Database Queries With dbGo (ADO) By design, a Delphi application runs in one thread. To speed up some parts of the application you might want to decide to add several simultaneous paths of execution in your Delphi application. Multithreading in Database Applications In most scenarios, database applications you create with Delphi are single threaded- a query you run against the database needs to finish (processing of the query results) before you can fetch another set of data. To speed up data processing, for example, fetching data from the database to create reports, you can add an additional thread to fetch and operate on the result (recordset). Continue reading to learn about the 3 traps in multithreaded ADO database queries: Solve: CoInitialize was not called.Solve: Canvas does not allow drawing.Main TADoConnection cannot be used! Customer Order Scenario In the well-known scenario where a customer places orders containing items, you might need to display all the orders for a particular customer along the total number of items per each order. In a normal single threaded application you would need to run the query to fetch the data then iterate over the recordset to display the data. If you want to run this operation for more than one customer, you need to sequentially run the procedure for each of the selected customers. In a multithreaded scenario you can run the database query for every selected customer in a separate thread- and thus have the code execute several times faster. Multithreading in dbGO (ADO) Lets say you want to display orders for 3 selected customers in a Delphi list box control. type   Ã‚  TCalcThread class(TThread)  Ã‚  private   Ã‚  Ã‚  Ã‚  procedure RefreshCount;  Ã‚  protected   Ã‚  Ã‚  Ã‚  procedure Execute; override;  Ã‚  public   Ã‚  Ã‚  Ã‚  ConnStr : widestring;   Ã‚  Ã‚  Ã‚  SQLString : widestring;   Ã‚  Ã‚  Ã‚  ListBox : TListBox;   Ã‚  Ã‚  Ã‚  Priority: TThreadPriority;   Ã‚  Ã‚  Ã‚  TicksLabel : TLabel;   Ã‚  Ã‚  Ã‚  Ticks : Cardinal;   Ã‚  end; This is the interface part of a custom thread class we are going to use to fetch and operate on all the orders for a selected customer. Every order gets displayed as an item in a list box control (ListBox field). The ConnStr field holds the ADO connection string. The TicksLabel holds a reference to a TLabel control that will be used to display thread executing times in a synchronized procedure. The RunThread procedure creates and runs an instance of the TCalcThread thread class. function TADOThreadedForm.RunThread(SQLString: widestring; LB:TListBox; Priority: TThreadPriority; lbl : TLabel): TCalcThread;var   Ã‚  CalcThread : TCalcThread; begin   Ã‚  CalcThread : TCalcThread.Create(true) ;   Ã‚  CalcThread.FreeOnTerminate : true;   Ã‚  CalcThread.ConnStr : ADOConnection1.ConnectionString;   Ã‚  CalcThread.SQLString : SQLString;   Ã‚  CalcThread.ListBox : LB;   Ã‚  CalcThread.Priority : Priority;   Ã‚  CalcThread.TicksLabel : lbl;   Ã‚  CalcThread.OnTerminate : ThreadTerminated;   Ã‚  CalcThread.Resume;   Ã‚  Result : CalcThread; end; When the 3 customers are selected from the drop down box, we create 3 instances of the CalcThread: var   Ã‚  s, sg: widestring;   Ã‚  c1, c2, c3 : integer; begin   Ã‚  s : SELECT O.SaleDate, MAX(I.ItemNo) AS ItemCount   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   FROM Customer C, Orders O, Items I   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   WHERE C.CustNo O.CustNo AND I.OrderNo O.OrderNo ;   Ã‚  sg : GROUP BY O.SaleDate ;   Ã‚  c1 : Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]) ;   Ã‚  c2 : Integer(ComboBox2.Items.Objects[ComboBox2.ItemIndex]) ;   Ã‚  c3 : Integer(ComboBox3.Items.Objects[ComboBox3.ItemIndex]) ;   Ã‚  Caption : ;   Ã‚  ct1 : RunThread(Format(%s AND C.CustNo %d %s,[s, c1, sg]), lbCustomer1, tpTimeCritical, lblCustomer1) ;   Ã‚  ct2 : RunThread(Format(%s AND C.CustNo %d %s,[s, c2, sg]), lbCustomer2, tpNormal,lblCustomer2) ;   Ã‚  ct3 : RunThread(Format(%s AND C.CustNo %d %s,[s, c3, sg]), lbCustomer3, tpLowest, lblCustomer3) ; end; Traps and Tricks With Multithreaded ADO Queries The main code goes in the threads Execute method: procedure TCalcThread.Execute;var   Ã‚  Qry : TADOQuery;   Ã‚  k : integer; begin  Ã‚  inherited;  Ã‚  CoInitialize(nil) ; //CoInitialize was not called   Ã‚  Qry : TADOQuery.Create(nil) ;  Ã‚  try// MUST USE OWN CONNECTION // Qry.Connection : Form1.ADOConnection1;   Ã‚  Ã‚  Ã‚  Qry.ConnectionString : ConnStr;   Ã‚  Ã‚  Ã‚  Qry.CursorLocation : clUseServer;   Ã‚  Ã‚  Ã‚  Qry.LockType : ltReadOnly;   Ã‚  Ã‚  Ã‚  Qry.CursorType : ctOpenForwardOnly;   Ã‚  Ã‚  Ã‚  Qry.SQL.Text : SQLString;   Ã‚  Ã‚  Ã‚  Qry.Open;   Ã‚  Ã‚  Ã‚  while NOT Qry.Eof and NOT Terminated do   Ã‚  Ã‚  Ã‚  begin   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  ListBox.Items.Insert(0, Format(%s - %d, [Qry.Fields[0].asString,Qry.Fields[1].AsInteger])) ;   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  //Canvas Does NOT Allow Drawing if not called through Synchronize   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Synchronize(RefreshCount) ;   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Qry.Next;   Ã‚  Ã‚  Ã‚  end;  Ã‚  finally   Ã‚  Ã‚  Ã‚  Qry.Free;   Ã‚  end;   Ã‚  CoUninitialize() ; end; There are 3 traps you need to know how to solve when creating multithreaded Delphi ADO database applications: CoInitialize and CoUninitialize must be called manually before using any of the dbGo objects. Failing to call CoInitialize will result in the CoInitialize was not called exception. The CoInitialize method initializes the COM library on the current thread. ADO is COM.You *cannot* use the TADOConnection object from the main thread (application). Every thread needs to create its own database connection.You must use the Synchronize procedure to talk to the main thread and access any controls on the main form.