The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm8 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm8 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm8 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
proper use of 'remove'
Author Message
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #5
RE: proper use of 'remove'
Here is an excerpt from the wikipedia article on Object Oriented Programming:

Quote:In programming languages an object is the composition of nouns (like data such as numbers, strings, or variables) and verbs (like actions, such as functions).

An object oriented program may be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent "machine" with a distinct role or responsibility. Actions (or "methods") on these objects are closely associated with the object. For example, OOP data structures tend to "carry their own operators around with them" (or at least "inherit" them from a similar object or class)...

The REMOVE "function" (or "command", or "method" if you prefer), is inherited from the most primitive of objects... as such, it can be applied to nearly anything (certainly any ITEM, CHAR (both NPC and Player), and possibly even more esoteric stuff like REGIONS (although I've never tried that sort of thing...) Using "dot notation" you can can cause the REMOVE to act on the referenced object... for example:

SRC.REMOVE
ACT.REMOVE
SRC.FINDLAYER.layer_hand1.UID.REMOVE

etc... or you can pass arguments to it and cause it to affect something else entirely... as in:

REMOVE SRC
REMOVE ACT
REMOVE <SRC.FINDLAYER.layer_hand.UID>

The wiki article goes on to say this:

Quote:...Objects can be thought of as encapsulating their data within a set of functions designed to ensure that the data are used appropriately, and to assist in that use. The object's methods typically include checks and safeguards specific to the data types the object contains...

An example of a safeguard that sphere has implemented in the REMOVE method is the protection of player CHAR objects... to remove a Player CHAR, the last argument of REMOVE must be a 1, as in:

SRC.REMOVE 1

or

REMOVE <SRC> 1

Quote:ok, so no arguments after the remove, remove should be left side, not right. thx man

There isn't really any difference, from a style perspective using SRC.REMOVE is a more "object oriented" way of writing your code... but there is also something to say for code readability, so in some cases it might be easier to "read" your code if you use the other style of passing an argument to the function/method.
(This post was last modified: 07-24-2013 11:19 AM by RanXerox.)
07-24-2013 11:15 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Messages In This Thread
proper use of 'remove' - Rattlehead - 07-24-2013, 04:10 AM
RE: proper use of 'remove' - Shaklaban - 07-24-2013, 04:26 AM
RE: proper use of 'remove' - Rattlehead - 07-24-2013, 04:55 AM
RE: proper use of 'remove' - amonvangrell - 07-24-2013, 08:18 AM
RE: proper use of 'remove' - RanXerox - 07-24-2013 11:15 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)