Encapsulation

can anybody explain to me what encapsulation is and how it is implemented..thankz in advance
ronald

The hard decision is how much to expose, as we're discussing here.
theAmerican

Similar Messages

  • What is difference between abstraction and encapsulation ?

    Hi,
    I am trying to figure out the difference between abstraction and encapsulation but confused.
    Both are used for data hiding then what is the exact difference ?
    Thanks.

    Tushar-Patel wrote:
    I am trying to figure out the difference between abstraction and encapsulation but confused.
    Both are used for data hiding then what is the exact difference ?This is the picture I have:
    When you encapsulate something you get an inside and an outside. The outside is the abstraction. It describes how the encapsulated entity behaves viewed from the outside. This is also called the type. Hidden inside is the implementation. It holds detail information about how the type's behaviour is accomplished.
    It's a very simplified picture but I think it's quite accurate and it works for me.

  • Help with encapsulation and a specific case of design

    Hello all. I have been playing with Java (my first real language and first OOP language) for a couple months now. Right now I am trying to write my first real application, but I want to design it right and I am smashing my head against the wall with my data structure, specifically with encapsulation.
    I go into detail about my app below, but it gets long so for those who don't want to read that far, let me just put these two questions up front:
    1) How do principles of encapsulation change when members are complex objects rather than primitives? If the member objects themselves have only primitive members and show good encapsulation, does it make sense to pass a reference to them? Or does good encapsulation demand that I deep-clone all the way to the bottom of my data structure and pass only cloned objects through my top level accessors? Does the analysis change when the structure gets three or four levels deep? Don't DOM structures built of walkable nodes violate basic principles of encapsulation?
    2) "Encapsulation" is sometimes used to mean no public members, othertimes to mean no public members AND no setter methods. The reasons for the first are obvious, but why go to the extreme of the latter? More importantly HOW do you go to the extreme of the latter? Would an "updatePrices" method that updates encapsulated member prices based on calculations, taking a single argument of say the time of year be considered a "setter" method that violates the stricter vision of encapsulation?
    Even help with just those two questions would be great. For the masochistic, on to my app... The present code is at
    http://www.immortalcoil.org/drake/Code.zip
    The most basic form of the application is statistics driven flash card software for Japanese Kanji (Chinese characters). For those who do not know, these are ideographic characters that represent concepts rather than sounds. There are a few thousand. In abstract terms, my data structure needs to represent the following.
    -  There are a bunch of kanji.
       Each kanji is defined by:
       -  a single character (the kanji itself); and
       -  multiple readings which fall into two categories of "on" and "kun".
          Each reading is defined by:
          -  A string of hiragana or katakana (Japanese phoenetic characters); and
          -  Statistics that I keep to represent knowledge of that reading/kanji pair.Ideally the structure should be extensible. Later I might want to add statistics associated with the character itself rather than individual readings, for example. Right now I am thinking of building a data structure like so:
    -  A Vector that holds:
       -  custom KanjiEntry objects that each hold
          -  a kanji in a primitive char value; and
          -  two (on, kun) arrays or Vectors of custom Reading objects that hold
             -  the reading in a String; and
             -  statistics of some sort, probably in primitive valuesFirst of all, is this approach sensible in the rough outlines?
    Now, I need to be able to do the obvious things... save to and load from file, generate tables and views, and edit values. The quesiton of editting values raises the questions I identified above as (1) and (2). Say I want to pull up a reading, quiz the user on it, and update its statistics based on whether the user got it right or wrong. I could do all this through the KanjiEntry object with a setter method that takes a zillion arguments like:
    theKanjiEntry.setStatistic(
    "on",   // which set of readings
    2,      // which element in that array or Vector
    "score", // which statistic
    98);      // the valueOr I could pass a clone of the Reading object out, work with that, then tell the KanjiEntry to replace the original with my modified clone.
    My instincts balk at the first approach, and a little at the second. Doesn't it make more sense to work with a reference to the Reading object? Or is that bad encapsulation?
    A second point. When running flash cards, I do not care about the subtlties of the structure, like whether a reading is an on or a kun (although this is important when browsing a table representing the entire structure). All I really care about is kanij/reading pairings. And I should be able to quickly poll the Reading objects to see which ones need quizzing the most, based on their statistics. I was thinking of making a nice neat Hashtable with the keys being the kanji characters in Strings (not the KanjiEntry objects) and the values being the Reading objects. The result would be two indeces to the Reading objects... the basic structure and my ad hoc hashtable for runninq quizzes. Then I would just make sure that they stay in sync in terms of the higher level structure (like if a whole new KanjiEntry got added). Is this bad form, or even downright dangerous?
    Apart from good form, the other consideration bouncing around in my head is that if I get all crazy with deep cloning and filling the bottom level guys with instance methods then this puppy is going to get bloated or lag when there are several thousand kanji in memory at once.
    Any help would be appreciated.
    Drake

    Usually by better design. Move methods that use the
    getters inside the class that actually has the data....
    As a basic rule of thumb:
    The one who has the data is the one using it. If
    another class needs that data, wonder what for and
    consider moving that operation away from that class.
    Or move from pull to push: instead of A getting
    something from B, have B give it to A as a method
    call argument.Thanks for the response. I think I see what you are saying.. in my case it is something like this.
    Solution 1 (disfavored):
    public class kanjiDrill{ // a chunk of Swing GUI or something
         public void runDrill(Vector kanjiEntries){
              KanjiEntry currentKanjiEntry = kanjiEntries.elementAt(0); // except really I will pick one randomly
              char theKanji = currentKanjiEntry.getKanji();
              String theReading = currentKanjiEntry.getReading();
              // build and show a flashcard based on theKanji and theReading
              // use a setter to change currentKanji's data based on whether the user answers correctly;
    }Solution 2 (favored):
    public class kanjiDrill{ // a chunk of Swing GUI or something
         public void runDrill(Vector kanjiEntries){
              KanjiEntry currentKanjiEntry = kanjiEntries.elementAt(0); // except really I will pick one randomly
              currentKanji.buildAndShowFlashcard(); // method includes updating stats
    }I can definitely see the advantages to this, but two potential reasons to think hard about it occur to me right away. First, if this process is carried out to a sufficient extreme the objects that hold my data end up sucking in all the functionality of my program and my objects stop resembling natural concepts.
    In your shopping example, say you want to generate price tags for the items. The price tags can be generated with ONLY the raw price, because we do not want the VAT on them. They are simple GIF graphics that have the price printed on a an irregular polygon. Should all that graphics generating code really go into the item objects, or should we just get the price out of the object with a simple getter method and then make the tags?
    My second concern is that the more instance methods I put into my bottom level data objects the bigger they get, and I intend to have thousands of these things in memory. Is there a balance to strike at some point?
    It's not really a setter. Outsiders are not setting
    the items price - it's rather updating its own price
    given an argument. This is exactly how it should be,
    see my above point. A breach of encapsulation would
    be: another object gets the item price, re-calculates
    it using a date it knows, and sets the price again.
    You can see yourself that pushing the date into the
    item's method is much beter than breaching
    encapsulation and getting and setting the price.So the point is not "don't allow access to the members" (which after all you are still doing, albeit less directly) so much as "make sure that any functionality implicated in working with the members is handled within the object," right? Take your shopping example. Say we live in a country where there is no VAT and the app will never be used internationally. Then we would resort to a simple setter/getter scheme, right? Or is the answer that if the object really is pure data are almost so, then it should be turned into a standard java.util collection instead of a custom class?
    Thanks for the help.
    Drake

  • Scheduled report with sub-reports  (Encapsulating page failed).

    Hello Everyone
    I am fairly new to reporting and SAP.
    I do have a main schedule report containing 4 sub-reports in the sections and 1 sub-report in the page header.
    The report runs fine in the Infoview development folder, But whenever its deployed in system_testing folder, it doesn't open and gives the following error:
    "ERROR IN FILE XXX:Encapsulating page failed."
    I talked to DBA to change the permission for the user, but they don't agree. since its a scheduled report, user can only access the instance of the report, not to run it.
    How can I make sure that the sub-reports don't run when user opens the report.
    I appreciate any help in advance
    Thanks and regards
    MJ

    Hi All,
    We have been facing the "Encapsulating page failed " error sporadic in our Crystal reports. It is not happening always.
    We have tried with different user accounts, it did not help much. Also tried various suggestion from the following SAP Notes:
    1536964 - Encapsulating page failed - The error change to Database error when the preference is changes
    1211088 - Error message "Encapsulating Page Failed" - This is not the case with our reports, we still have some reports facing the same error without an subreports in it
    1543412 - Infoview warning: "Error in File xxx : Encapsulating page failed - tried implementing the recommendation , but no help
    1900672 - Error: Encapsulating page failed while viewing Crystal Reports based on stored procedures in BOXI 3.1  -- Our reports are not based on stored procedures.
    We have faced this error in many different version of BOXI 3.1 like SP4.1, SP7.1, SP7.2. But the behaviour is similar. We have a clustered machine with 2 BOE servers and 2 Tomcat servers.
    I have tried activating E2E tracing, but I really couldn't understand the reason for error from the logs. Our reports connect to datasource using webservices.
    some information from the error traces.
    Verkapseln der Seite nicht möglich.. Internal error: CrpeMgrPEEncapsulatePageEx
    I would like someone to help me troubleshoot the problem. I can share the logs if needed. Please direct me to the correct forum if this is outdated.
    Regards,
    Prarthana

  • Exchange 2013 - Outlook 2010 - 550 5.1.0 RESOLVER.ADR.InvalidInSmtp; encapsulated INVALID address inside an SMTP address

    Hello, 
    I have issue when sending email to some addresses. Server respond with:
    Remote Server returned '550 5.1.0 RESOLVER.ADR.InvalidInSmtp; encapsulated INVALID address inside an SMTP address (IMCEAINVALID-)'
    My enviroment: Exchange 2013, Outlook 2010 - no cached mode. Issue happend with two email addresses but not always.
    Any suggestion, how to resolve issue?
    Thx.

    Hi Tomas,
    Does this issue occur in OWA? How is the impact, only one user or all users?
    Please try to run Outlook under safe mode to avoid add-ins and AVs.
    If there is any 3rd party add-ins, please try to disable them for testing.
    Thanks
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Mavis Huang
    TechNet Community Support

  • Encapsulation vs. performance

    We are creating a J2EE application with an O-R mapper to solve the persistence problems. We plan to create Java objects which encapsulate certain aspects by creating a service interface. These services use persistent objects backed by some database tables.
    Now we have some decisions which need information of all kinds of services. With SQL you would do a big join over a lot of tables and get a small result. Using OO you would ask service A getting 5000 objects and merge it with the result of service B getting 6000 objects...
    I don't have to mention that the OO version is unbearably slow. The SQL version is quite fast but breaks encapsulation. The writer of the query has to know the implementation details of all services.
    Is there any solution? Somthing like the service provides a part of a query and the caller "joins" them with its own query?

    >
    Is there any solution? Somthing like the service
    provides a part of a query and the caller "joins"
    them with its own query?This is easy to generalize given that a service does know the attibutes.
    Each attribute generates the following java properties...
               class Attribute
                   String op1;
                   String op2;
                   Operand operand;
    This is wrapped in a service type
              class SingleServiceQuery
                    String serviceName
                    Collection of Attributes
              class  ServiceQuery
                    Collection of SingleServiceQuery
    In the database layer you have a generalized routine to map the serviceName to the database, and attribute types and names.
    You can derive this dynamically or simply insist that the service descriptor itself provide (even do it the database if you want.)
    Commonality is based on common attribute names.
    The query is built dynamically.

  • Encapsulating Data in XML Output in CDATA tags

    Hi,
    I have a simple pdf fillable form that I created in LiveCycle Designer ES that saves/submits form data as XML for parsing into a database.  The database parser requires all form data to be encapsulated into CDATA tags inside the XML fieldnames or it will not process it.  Can anyone give some pointers to force the XML output to encapsulate the data inside CDATA tags within the XML fieldnames in my output XML file?  Thanks.
    Dan

    Hi Dan,
    Can you post a sample of what you want the xml to look like.  If I understand correctly, it sounds like a very strange parser.  I would imagine you would have to preprocess the xml on the server.
    Regards
    Bruce

  • Thread-safe design pattern for encapsulating Collections?

    Hi,
    This must be a common problem, but I just can't get my head around it.
    Bascially I'm reading in data from a process, and creating/updating data structuers from this data. I've got a whloe bunch of APTProperty objects (each with a name/value) stored in a sychronized HashMap encapsulated by a class called APTProperties. It has methods such as:
    addProperty(APTProperty) // puts to hashmap
    getProperty(String name) // retreives from hashmap
    I also want clients to be able to iterate through all the APTProperties, in a thread safe manner . ie. they aren't responsible for sychronizing on the Map before getting the iterator. (See Collections.synchronizedMap() API docs).
    Is there any way of doing this?
    Or should I just have a method called
    Iterator propertyIterator() which returns the corresponding iterator of the HashMap (but then I can't really make it thread safe).
    I'd rather not make the internal HashMap visible to calling clients, if possible, 'cause I don't want people tinkering with it, if you know what I mean.
    Hope this makes sense.
    Keith

    In that case, I think you need to provide your own locking mechanism.
    public class APTProperties {
    the add, get and remove methods call lock(), executes its own logic, then call unlock()
    //your locking mechanism
    private Thread owner; //dont need to be volatile due to synchronized access
    public synchronized void lock() {
    while(owner != null) {
    wait();
    th = Thread.currentThread();
    public synzhronized void unlock() {
    if(owner == currentThread()){
    owner = null;
    notifyAll();
    }else {
    throw new IllegalMonitorStateException("Thread: "+ Thread.currentThread() + "does not own the lock");
    Now you dont gain a lot from this code, since a client has to use it as
    objAPTProperties.lock();
    Iterator ite = objAPTProperties.propertyIterator();
    ... do whatever needed
    objAPTProperties.unlock();
    But if you know how the iterator will be used, you can make the client unaware of the locking mechanism. Lets say, your clients will always go upto the end thru the iterator. In that case, you can use a decorator iterator to handle the locking
    public class APTProperties {
    public Iterator getThreadSafePropertyIterator() {
    private class ThreadSafeIterator implements Iterator {
    private iterator itr;
    private boolean locked;
    private boolean doneIterating;
    public ThreadSafeIterator(Iterator itr){
    this.itr = itr;
    public boolean hasNext() {
    return doneIterating ? false : itr.hasNext();
    public Object next() {
    lockAsNecessary();
    Object obj = itr.next();
    unlockAsNecessary();
    return obj;
    public void remove() {
    lockAsNecessary();
    itr.remove();
    unlockAsNecessary();
    private void lockAsNecessary() {
    if(!locked) {
    lock();
    locked = true;
    private void unlcokAsNecessary() {
    if(!hasNext()) {
    unlock();
    doneIterating = true;
    }//APTProperties ends
    The code is right out of my head, so it may have some logic problem, but the basic idea should work.

  • Double quote encapsulated identifiers in sql developer 1.5.1

    hello,
    i migrated a mysql database to oracle using the sql developer 1.5.1 on linux. unfortunately i'm using some reserved words in my table name / columns. how is it possible to generate an import script that uses double quote encapsulated identifiers? in the migration workbench, there is an option named "Create ANSI-compilant names" which should do what i need, but i cannot find this option in sql developer.
    thank you for your help. regards,
    sebastian

    I'm not sure what your question is; Did you migrate successfully? How do you generate an import script? What is failing? Can you provide an example?
    K.

  • Which option best fits the definition of encapsulation ?

    Hi Folks,
    In this test question :
    How can you implement encapsulation.
    A) By making methods private and variable private
    B) By making methods are public and variables as private
    C) Make all variable are public and access them using methods
    D) Making all methods and variables as protected
    What could be the answer ?
    I guess making variables private and accessing them with methods with appropriate access levels would be the way to go for encapsulation.But I am not able to relate any of the options with that.
    I would appreciate if I receive some feedback on this.
    Thank you for your consideration.

    Surely to answer this question you must first state the definition of encapsulation to which you subscribe and then evaluate each of the answers in terms of that definion.
    So, which definition would you like to use?
    Some would say that using a standardised definition might help; and fortunately the International Organisation for Standardization has published just such a definition in its standard: Open Distributed Processing, ISO/IEC 10746. There, they define encapsulation as:
    "... the property that the information contained in a modelled entity is accessible only through interactions at the interfaces supported by that modelled entity."
    You may or may not agree with the ISO on this, but let's run with their definition and see where it gets us, shall we?
    Firstly, encapsulation concerns accessibility, and on this point, your alternatives are clearly and crisply distinguishable. This is good.
    Secondly, the, "Information," referred to here is not just data: it also includes behaviour, i.e., methods. Thus it makes little sense to distinguish between data-encapsulation and method-encapsulation; both a method and a variable can be a point of access of an class. This somewhat cheapens all the alternatives given in your test, which is not good.
    Thirdly, encapsulation is not binary: it is not usually a yes/no answer; so we will almost certainly have degrees of encapsulation and thus can rate the answers given in your test on this gradient.
    Fourthly, it can be shown, if you begin with the above definition, that encapsulation's benefit is in minimising the number of potential dependencies with the highest probability of modification event propagation. Thus we can also rate the answers given in your test by asking how each exposes classes to such potential dependencies.
    Lastly, some of the answers you've been given are wonderfully vague, so we'll have to watch our step; frankly, some of them, because of their vagueness, are discountable for reasons that go beyond encapsulation and deep into the realm of common sense.
    Let's take a look at the answers, though before we do, we must decide whether the answers pertain to a specific, single class or to all classes in our system: we shall presume the latter, that these answers concern a general approach to programming, rather than advising on a single class's design (it actually makes a difference).
    "A) By making methods private and variable private."
    Well, by making all methods and variables private you will effectively deny all access to information stored in all classes: this would make all your classes unusable, which makes the question of any of their properties a moot point.
    "B) By making methods public and variables private."
    (The vagueness begineth: it's presumed that this implies making all methods public.) This would give access to the information of all the classes via all their methods, which means that none of their behaviours are information-hidden, even though all their data is information-hidden. This is better than (A) but not an ideal way to design a system: given that all methods in all classes are accessible, then potential dependencies may form on all of them and thus changing any method could potentially ripple to all other classes in the system: a deeply costly prospect.
    "C) Make all variables public and access them using methods."
    This makes all data accessible and some unspecified subset (perhaps all) of behaviours accessible in all classes. This would seem to offer more accessibility than (B) and so would offer a greater modification event propagation probability than (B). This thus seems less satisfactory than (B).
    "D) Making all methods and variables protected."
    Protected accessibility is theoretically problematic, but it implies that there are at least some clients that have full access to all classes, with the consequent costly modification event propagation probability. This alternative, however, is discountable for reasons that lie beyond encapsulation, as it implies that the only way that classes in different packages could communicate is if the classes are subclasses of one another; it's almost impossible to imagine a semantically coherent system in which all these classes were subclasses of one another, so this alternative can be rejected on the grounds of implausibility (if not silliness).
    So, if we go with ISO above, then we're left with the following alternatives in order of decreasing appropriateness: B, C, D and A.
    So B would be my answer, though I'd have to swallow hard to write it.
    For more on encapsulation according to the ISO, see, "How to encapsulate software (Part 1)," here:
    http://www.edmundkirwan.com/encap/overview/paper7.html
    Regards,
    Ed.

  • Encapsulation command in subif

    Greets,
    I have a 2610 router and I am attempting to enable DOT1Q on eth0/0.1 for router-on-a-stick configuration.
    My sh ver is as follows:
    Router>sh ver
    Cisco Internetwork Operating System Software
    IOS (tm) C2600 Software (C2600-I-M), Version 12.2(8)T5, RELEASE SOFTWARE (fc1)
    TAC Support: http://www.cisco.com/tac
    Copyright (c) 1986-2002 by cisco Systems, Inc.
    Compiled Fri 21-Jun-02 08:50 by ccai
    Image text-base: 0x80008074, data-base: 0x80A2BD40
    ROM: System Bootstrap, Version 11.3(2)XA4, RELEASE SOFTWARE (fc1)
    Router uptime is 39 minutes
    System returned to ROM by reload
    System image file is "flash:c2600-i-mz.122-8.T5.bin"
    cisco 2610 (MPC860) processor (revision 0x203) with 28672K/4096K bytes of memory.
    Processor board ID JAD042108TF (1440777694)
    M860 processor: part number 0, mask 49
    Bridging software.
    X.25 software, Version 3.0.0.
    1 Ethernet/IEEE 802.3 interface(s)
    32K bytes of non-volatile configuration memory.
    8192K bytes of processor board System flash (Read/Write)
    Configuration register is 0x2102
    Now the problem is I can not enter the encapsulation command as you can see here:
    Router#conf t
    Enter configuration commands, one per line. End with CNTL/Z.
    Router(config)#int eth0/0.1
    Router(config-subif)#encapsulation
    ^
    % Invalid input detected at '^' marker.
    Any reason for this? I thought IOS 12.2 should have dot1q capability.
    Cheers

    Hi Dan.
    you're right as this document does.
    http://www.cisco.com/en/US/products/hw/routers/ps259/prod_bulletin09186a00800921e4.html
    But you need to make sure that by using the cisco navigator.
    http://tools.cisco.com/ITDIT/CFN/jsp/index.jsp
    As far as I see you should use c2600-is-mz.122-4.T.bin IOS that is IP-PLUS feature set.Kindly check the ios you want for sure!
    Edit : Jon and Glen are absolutely right. I didn't see your replies.
    Hopes this helps
    Thot

  • I need the coding example for encapsulation

    hi all
    i need the coding example for encapsulation
    thanks in advance

    hi all
    i need the coding example for encapsulation
    thanks in advanceI see a man, hes trapped on the other side.. what Sam?... yes ... hes wearing a hood, he's a hooded gentleman, perhaps a monk who practised the black arts.... he says... "google for the answer"...

  • Encapsulation Error in Crystal Reports using Web Service Connection

    Hi Experts,
    I'd like to request help in investigating an issue we are currently having in Crystal Reports.  Basically, the solution design is:
    -Web Service is Used as connection
    -Dynamic Hyperlink value is used to access another Crystal Report
    Issue: Dynamic Hyperlink value is based on a summary.  We are getting Encapsulation Error message whenever we try to click a link having 30k value.
    Does anyone here can give us some tip on how to investigate the issue?  For such cases, which component (datasource, CR, etc.) of the solution normally causes the issue?  Are there any limitation in using Web Service for Crystal Reports?
    We'd greately appreciate any help here.
    Kind Regards and Many Thanks,
    Mark

    Hi Mark,
    There could be many reasons for this rather 'generic' error. Is the Business Objects Enterprise clustered?
    Also, could you try saving both the Main and the target reports to the Enterprise with the 'No printer' option checked.
    (File > Page Setup> No Printer).
    Also, what happens when the target report is viewed on its own?
    Let me know how it goes!
    -Abhilash

  • Constant values and encapsulation

    Hi All,
    lookat the code below:
    class Test{
    public static final int flag = 10;
    Public static void main(String args[])
    System.out.println(i);
    }here the constant value i is used inside the same class.
    Now generally, we use to make separate java file for all constant values and get the values:
    For example:
    class UIConstants{
    public static final int flag = 10;
    }and call this constants values where ever neccessary:
    class Test{
    Public static void main(String args[])
    System.out.println(UIConstants.flag);
    }In most of the the time, i have seen second case is used, but it avoids the encapsulation concepts, since making variable private to public.
    What is the advantages of making in this way?or is there any other reason for using this way?

    Are they thread-safe? No! Not by default anyway.Anything immutable and final is thread safeAs long as the immutable object really is internally
    immutable and has no operations that have
    side-effects on objects outside of the object.
    COuld you shed some light on this.
    For example even a final immutable PrintStream (which
    system.out and system.err are not... see
    System.setOut()) is not necessarily threadsafe
    because two threads could be writing to the same
    stream at the same time.I didnot know PrintStreams were immutable

  • Private - encapsulation or inheritance (but not both)

    Suppose that your class has some internal computation or logic that it performs, and that you wish to encapsulate this in a method that can not be called by other classes.
    You provide public methods that filter, format, or somehow modify the input and/or output of this encapsulated method.
    class pseudoCodeClass {
    private coreLogic(Objects inputs) {
    Maybe some complicated math stuff;
    Or password stuff;
    Or pay out functionality for a slot machine;
    return(stuff);
    public getUserData(inputs) {
    format/check the inputs;
    coreLogic(inputs);
    format the output;
    Now, how do you leveradge the power of OO inheritance to extend the internal logic that you encapsulated? If you make the interal logic private, then it's encapsulated, but you lose the power of OO inheritance, or you can make it protected and lose the encapsulation. I thought an OO language was supposed to have encapsulation and inheritance, not encapsulation or inheritance. (And, yes I realize that there is some techincal sense in which private methods are still inherited, but I'm talking about the general OO concept of inheritence where it includes overriding or extending.)
    Suppose you want to:
    class pseudoCodeSubclass extends pseudoCodeClass {
    private coreLogic(inputs) {
    super.coreLogic(inputs);
    additional more specific code; // The whole point of OO inheritence
    You can't extend super.coreLogic through your access to super.getUserData because it does all sorts of filtering and formating that is not a part of the internal logic that you wish to extend/override. And, providing other more public accessor methods to the core logic just defeats the encapsulation.
    I have seen many discussions of this, but none with any answers to my satisfaction. One line of answers is that you don't want encapsulated stuff to be part of your object's contract. Some times people with this sort of answer even suggest coppying the code from the super class into the subclass. People with this sort of answer don't seem to even want the option to use inheritence because of the obligation that might go with it. But without the option of inheriting encapsulated logic, they are forced to either use cut and paste (in an OO language that seems wrong to me) or to abandon encapsulation all together. Being forced into those 2 extreems doesn't seem to me like it would simplify future support of your class, and future support seems to be the primary point of the contract line of response.
    The way some people argue about this, I amost want to say - Look! In C you can encapsulate everything you want, and never have to worry about inheritance. (But you still shouldn't have to cut and paste.)
    Another line of response that I have seen is that private methods should only be used in breaking up code that would have gone into a single method. In other words, the private methods aren't really 'units of program logic' they are just a mater of organizational convenience. So if you had:
    public oneBigMessyMethod() {
    100 lines of A;
    100 lines of B;
    100 lines of C;
    you could maintain it as:
    public oneBigMessyMethod() {
    a();
    b();
    c();
    private a() {
    100 lines of A;
    private b() {
    100 lines of B;
    private c() {
    100 lines of C;
    I agree private works well in this situation. Presumably since a(), b() and c() are divided up for convenience rather than because of distinct logical function, you wouldn't want to extend just a() with inheritance. But this also seems to dodge the question. Just because sometimes you might not want encapsulated functionality to be available for extention, does not mean that you would never want it. I think that I'd also have to disagree with the permise that encapsulation is only for hiding stuff that is just a convention of convenience. The main point of encapsulation is to hide information or functionality. If encapsulation is only used for the convenient breakdown of your primary functionality, then all of your primary functionality is public, package or protected. That does make it inheritable. But, now all of the primary functionality is a part of the contract for that class.
    Is there an answer to this issue that does not ignore the value of either encapsulation or inheritance?
    There is one way that I can see to do exactly what I think should be possible. That is to put only classes from the same hierarchy in a package. Then both package and protected effectively provide encapsulation with the ability to inherit (and you do still have the option to use private or final if there is a case where you want to disable inheritence).
    What I'd like to know is - What do people actually do? In the real world, do people:
    1) use private + cut and paste
    2) use package/protected + self discipline
    Where 2 is that you drop encapsulation within your package but then excercise self dicipline and just don't call/access stuff that you intend to be for that class only...
    Or is there some 3rd thing that I'm missing? I've tried to think how maybe you could design your objects in such a way that you'd never need to inherit/extend something that you would also want to encapsulate. But I just don't see how that's possbile.
    So, what do people do?
    Chris

    First of all, you have got to understand that I am not
    suggesting that Private and Final should be changed or
    removed from java. It looks to me like there should
    be an additional access option (and there was
    originaly).
    I understand that if a class inherits something, it
    could expand the access or put public accessor methods
    around it. Obviously with ultra sensitive code this
    would be a nightmare. So private and final are very
    important. But if the very possibility of another
    class expanding a given level of access is a reason
    for not even having that level of access, then why do
    we have package and protected?
    There are a great number of places in common coding where that access does restrict usage in a usable way.
    >
    If the only re-use of your code that you allow is
    through the public interface, what do you even need an
    OO language for? Just for the polymorphism and a
    different way to organize your code?
    Not sure what you mean by that but see below.
    But as I've said. I've seen this whole thing argued a
    number of times. But what I haven't seen is any
    explanation of what people who take the poslition that
    I'm taking actually do when they write code. Because
    I can sit here with a bunch of other people and say 'I
    wish Java had this or that'. And then of couse a
    bunch of people will resopond and say 'no that's dumb'
    or 'I don't see the point'. But at the end of the
    day, Java still is what it is. So, arguing about what
    it 'should be' is not going to effect how anyone
    codes.
    Sure it can. That is why java now has assert().
    So, what I started out wanting to know is how people
    actually code. Particularly people who wish that Java
    had a subclass only access modifier.
    I don't wish that.
    Perhapse I should also be asking about how things are
    done by people who see this level of access as
    unnececary. How they code is easy enough to
    understand. Making everything that is not intended to
    be accessed by any other class private is easy enough
    to do. But what would be interesting to know is how
    do you design your classes to leveradge inheritance if
    you do this. Maybe there is some way of desinging
    around ever having 'internal functionality' that you
    would want to extend and I'm just not getting it.
    There are three broad classifications of objects.
    1. Those that only use encapsulation
    2. Correct inheritence hierarchies
    3. Incorrect inheritence hierarchies
    The first of those, which I consider most classes to fall into, do not need this.
    The third area occurs when programmers use inheritence as a convenience mechanism to propogate behavior amoung different classes rather than using encapsulation as should be done. They don't understand the difference between "is-a" relationships (design) and coding convienence. I would estimate that at least 50% of existing object hierarchies fall into this area. Since in this case the entire design is wrong an extension is not needed.
    The second area is the only correct area where this might be needed. Since I personally believe that very few classes belong in hierarchies and this proposed extension would only be useful in a sub fraction of those. Since the correct usage is so small I don't think it would be useful addition to the language.

  • Encapsulating web services in CAF core

    Hi,
    I am trying to call external services namely web services in caf core. I read the earlier posts and i guess I am missing out on something.
    1. what is the difference between encapsulating external service as entity service VS application service. For example, I am trying to call the PurchaseOrderVendorAddress_WSD webservice. It takes vendorID and purchaseorderID as input and returns vendor address. What should I use and why?
    2. I checked out CAF core tutorial. It talks about encapsulating RFC as application service. Is it same for web service? I mean can I assume the same approach is valid for web service
    Many thnx,
    Mayukh

    did you follow the tutorial "81 Using a Web Service as External Service (Service)"?
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/11669cea-0c01-0010-63b2-b98c35b1b370
    you can't be lost after that. otherwise you're in big trouble my friend...

Maybe you are looking for

  • HP Laserjet P2015

    I just recently purchased a 16GB iPhone. When I plug it into my computer my HP Laserjet P2015 stops responding and will not print. I've tried uninstalling and reinstalling it, but the only way to get it to work is to unplug my iPhone from my computer

  • Installing Win 7 Pro as VM on Macbook Pro with 128G SSD

    Hi there, I've been searching for some good tips about installing Win 7 Pro as a VM on my new Macbook Pro (4GB i7 version) with a 128 SSD. Here is what I have and need to achieve: I have  Parallel 6 to set up the VM; Win 7 Pro 32-bit or 64-bit. Needs

  • Mixing Arial and webdings fonts in the same dynamic text.

    I'm building a stock ticker in Flash where I have to display some symbols using webdings for up or down. The rest is Arial font. I've tried everything. Creating css, using font tags, textformat etc... webdings always shows as a roman chars, not symbo

  • How to crop many nearly identical images the exact same amount?

    I need to crop many nearly identical images in a square shape. I want them to all be cropped so they look the same size. What is the best way to do this so they are all cropped the same?

  • Why You Can't Load Some Images On Your 5th Generation ipod

    Why You Can't Load some images on your 5th Gen ipod. - OK here is the scoop: I could not load some images on my 5th gen ipod and yet other images would load no problemo. Images were JPEG, jpg, PSD (all approved image types for the 5th gen ipod) - Aft