Encapsulation Question

Hi
I have my GUI components in class Gui.
I need to access the components from another class.
In this time the variables that holds the componentes are protected.
In this way I can to access the components from another classes.
BUT...
And the encapsulation paradigm here?, am I wrong?
Regards

Something else to consider:
It is pretty rare that objects outside your class really need direct access to the components. Think about creating methods that provide an interface for the external objects to access your class, then have your class take care of getting/setting the state of the user interface components.
If you really want to do encapsulation right, I suggest that you do a web search for the Model-View-Controller (also called MVC) design pattern.
- K

Similar Messages

  • Encapsulation questions

    i have two questions about encapsulation. i am unclear of what exactly this is.
    1) does encapsulation mean protecting data by only accces through getter/setter methods. or does it mean providing different and hidden implementations of a set and public method. i guess in this seond method i am really talking about interfaces where as a developer you are don't know about the implementation works and it may change but doesn't effect you. anyway is it either of these both of these.
    2) in relation to oo programming is encapsulation a feature or benefit of oo. can you have encapsulation without oo? can you have oo without encapsulation?
    ok well that was actually more than two questions i guess...

    It's a feature and a benefit. I read from book written in 93 that encapsulation is tieing the data and methods together. Well I have somewhat different opinnion what it mean in practice.
    It means that there exists so called black-box princible. User doesn't have to know what's happening inside the instance. He only needs to take care of the input and the output. This means in practice isolating the input to set-methods and the output to get-methods.
    Encapsulation doesn't make programming any easier at first, but it makes programming easier in future. You can change the context and actions of the class but still the class remains usable from outer context without modifications. This can be extended of course to all kinds of oop-patterns but this is the basic princible.

  • SCJA question about encapsulation

    I was taking an SCJA practice exam and came across this question...
    Which two are true regarding the class diagram...
    Customer
    -name : String
    -phoneNumber : String
    +getName() : String
    +setName( name : String ) : void
    +getPhoneNumber() : String
    Obviously answer a. which was "The name attribute is private" was correct, however i incorrectly picked out the next correct answer which turned out to be b."The customer class is well encapsulated".
    Whilst this may be a 'small' case of the sour grapes :-) i thought then that to be a well encapsulated class there would also need to be a setter method for the phoneNumber variable, and that seeing as there wasn't in this case it couldn't be well encapsulated, despite being moderately encapsulated.
    Does anyone have any thoughts on this? Is there often valid reason to not include setter methods for your private instance variables?
    Thanks

    I am new to the study of OO and Java but you ask for thoughts. I seems that encapsulation does not require that each instance variable have a getter and a setter method, but that the variables be protected (private) and only accessible through the class methods such as getter and setter.
    These variables are sometimes called properties of the class and can be read/write, read-only, or write-only. It also seems that if you were to have a read-only property and you provided a setter method to change it, then you have given other classes the ability to change a read-only attribute for you class. The class is encapsulated but it is no longer well-encapsulated because the references are no longer minimized.
    In other words it would create a tighter coupling than necessary. I have included a definition for encapsulation which refers to the getter and setter methods and coupling which refers to "well encapsulated".
    Encapsulation helps hide implementation behind an interface
    Encapsulated code has two features:
    1 Instance variables are kept protected (usually with private modifier).
    2 Getter and setter methods provide access to instance variables.
    Coupling refers to the degree to which one class knows about or uses members of another class.
    Loose coupling is the desirable state of having classes that are well encapsulated, minimize references to each other, and limit the breadth of API usage.

  • Question about Encapsulation

    I have two classes that have a parent-child relationship sort of.
    interface IProject{
          void doIt();
    class Project implements IProject{
         List architectures;
         public doIt(){
    class Architecture {
         Project project;
    }The question is how do I identify which project the architecture belongs to properly?
    architecture is not a project but it does have a project and sometimes I need to know which project the architecture belongs to. So I return project not as a way to get the project from architecture, but as a way to identify which project the architecture belongs to. But it seems wrong to expose project from within architecture. But at the same time, project does not make up any of architectures behavior except if you call 'belonging' a behavior.
    Maybe the answer is if you want to know which project the architecture belongs to you have to ask each project? This bidirectional relationship seems a bit odd. Maybe I can return from architecture a Project id or some kind of identifier but not the actual project?
    In fact I dont think the architecture even needs to hold a reference to the project since its not using any behavior from the project. But I do need a sound way to indicate which project the architecture belongs to. preferrably from the architecture.

    The question is how do I identify which project the
    architecture belongs to properly?
    By the way you phrased your question, you want to know what Project a given instance of Architecture belongs to. In this case, Architecture should have a reference to Project. I would do something like:
    final public class Architecture {
      final transient private Project parent;
      public Architecture(final Project parent) {
             super();
             this.parent = parent;
      // I am not providing an accessor method, so I have not yet 'exposed' the Project.
    architecture is not a project but it does have a
    project and sometimes I need to know which project
    the architecture belongs to. So I return project not
    as a way to get the project from architecture, but as
    a way to identify which project the architecture
    belongs to. But it seems wrong to expose project
    from within architecture. But at the same time,
    project does not make up any of architectures
    behavior except if you call 'belonging' a behavior.
    Belonging behavior indicates a dependency, which in Java is normally achieved by composition (see above).
    Maybe the answer is if you want to know which project
    the architecture belongs to you have to ask each
    project? You lost me there. You went from Project to Architecture back to Project. What way are you navigating?
    This bidirectional relationship seems a bit
    odd. Maybe I can return from architecture a Project
    id or some kind of identifier but not the actual
    project?
    That is fine. However, the id properly belongs within Project itself. IMO.
    In fact I dont think the architecture even needs to
    hold a reference to the project since its not using
    any behavior from the project. This requirement contradicts:
    But I do need a sound
    way to indicate which project the architecture
    belongs to. preferrably from the architecture.Which is it? Something A cannot both be A and not A at the same time.
    - Saish

  • Question regarding ScrollView and pageControl with multiple XIBs

    Hi,
    I am very new to iPhone programmming and OO type programming in general so please forgive me for my basic questions.
    I am trying to set a paging scrollview up with each page being loaded from a different XIB and put into a view controller. This viewcontroller is attached to a scrollview that's put on a "Detail" view. I have this working OK with blank XIB pages.
    My question is, when I start adding fields/buttons to the different XIBs how should I then process the actions etc. Do I create a seperate .h and .m file for each XIB and add the individual screen processing into the individual classes or do I use a single class (the "Detail" screen) and do all the processing in that class?, is that even possible?
    I do hope that this makes sense. I'm still going through the basic learning books and I'm maybe trying to run before I can walk.
    Any help is most appreciated.
    Thanks

    Hi Ziximo, and welcome to the Dev Forums!
    Ziximo wrote:
    I am very new to iPhone programmming and OO type programming in general so please forgive me for my basic questions.
    No forgiveness is necessary. You came to the right place.
    I am trying to set a paging scrollview up with each page being loaded from a different XIB and put into a view controller. This viewcontroller is attached to a scrollview that's put on a "Detail" view. I have this working OK with blank XIB pages.
    In case it's useful to you, here's a thread which shows how to use the PageControl sample app as the template for what you're doing: [Re: Flipping through views help|http://discussions.apple.com/thread.jspa?messageID=10417960&#10417960].
    My question is, when I start adding fields/buttons to the different XIBs how should I then process the actions etc.
    The advice you have from thomas-r is right on target, so I'll just try to add to that. Firstly, I think you may be making a diligent attempt at "top-down" design, which is commendable. However there's a dirty little secret that working programmers don't share with managers: Quite often we don't produce the functional specification until we get the code working.
    In other words, thomas-r's reference to Murphy isn't an insult. That's just how software gets designed.
    In general, the decision to make a new class should be based on encapsulation and re-usability. For example when you get a memory warning, you might want to release all of the resources required for a screen that isn't currently visible. If that screen and its controller can be fully regenerated from one nib, this can be an easy task.
    As another example, say the top-level controller is an instance of your ScrollViewController class. If you limit that controller to managing the scroll view and page control, you'll probably have a class you can reuse the next time you need a paging scroll view. But if you pack the functionality for multiple content views into that same controller, the class will only be useful for an identical app.
    .. or do I use a single class (the "Detail" screen) and do all the processing in that class?, is that even possible?
    So, no, I would definitely not attempt to put all the control in one class. Yes, it's possible, but besides being bad practice, it's awkward to implement. For example, when you make a nib which is owned by a view controller, it's easy to connect that controller's outlets and action methods to controls which are defined in that nib. There are ways to connect controls to an object defined in another nib, but it's much more difficult. It's not a "natural" configuration, and that by itself should give us second thoughts about our design. On the other hand, if we make one giant nib which is owned by the top-level controller, memory management goes out the window. We would need to unload everything in that nib to gracefully handle a memory warning.
    Do I create a seperate .h and .m file for each XIB and add the individual screen processing into the individual classes ...
    Yes. This gives us the reusability and encapsulation we want. The only remaining question is: "Do I need a separate controller class with it's own custom xib for each screen?". Well you may not. There could be two or more screens that are so similar (e.g. the same layout and functionality but with a different image) they can each use an instance of the same controller class and share the same xib.
    I usually start with a different controller class and a different xib for each screen. Then, near the end of the project, I'll look at all those controllers and see if two or more are nearly identical. If so, I might get rid of one or more classes, and possibly one or more xibs as well. But I'd almost never assume I can merge two controller classes at the outset. If I did that, I might start adding kludges to the merged class as I found differences between the screens I hadn't seen earlier. When the merged class finally got too complex for anyone to maintain, the job of splitting it up might be nasty.
    I do hope that this makes sense.
    I think that's my line.
    I'm still going through the basic learning books and I'm maybe trying to run before I can walk.
    If you've suceeded in getting the skeleton working--i.e. you're paging through blank screens, each with it's own vanilla controller/xib, without any bugs, I'd say you're more than ready for the question you're asking here. And it's a very good question.
    \- Ray

  • 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

  • ColdFusion 11: custom serialisers. More questions than answers

    G'day:
    I am reposting this from my blog ("ColdFusion 11: custom serialisers. More questions than answers") at the suggestion of Adobe support:
    @dacCfml @ColdFusion Can you post your queries at http://t.co/8UF4uCajTC for all cfclient and mobile queries.— Anit Kumar Panda (@anitkumar85) April 29, 2014
    This particular question is not regarding <cfclient>, hence posting it on the regular forum, not on the mobile-specific one as Anit suggested. I have edited this in places to remove language that will be deemed inappropriate by the censors here. Changes I have made are in [square brackets]. The forums software here has broken some of the styling, but so be it.
    G'day:
    I've been wanting to write an article about the new custom serialiser one can have in ColdFusion 11, but having looked at it I have more questions than I have answers, so I have put it off. But, equally, I have no place to ask the questions, so I'm stymied. So I figured I'd write an article covering my initial questions. Maybe someone can answer then.
    ColdFusion 11 has added the notion of a custom serialiser a website can have (docs: "Support for pluggable serializer and deserializer"). The idea is that whilst Adobe can dictate the serialisation rules for its own data types, it cannot sensibly infer how a CFC instance might get serialised: as each CFC represents a different data "schema", there is no "one size fits all" approach to handling it. So this is where the custom serialiser comes in. Kind of. If it wasn't a bit rubbish. Here's my exploration thusfar.
    One can specify a custom serialiser by adding a setting to Application.cfc:
    component {     this.name = "serialiser01";     this.customSerializer="Serialiser"; }
    In this case the value - Serialiser - is the name of a CFC, eg:
    // Serialiser.cfccomponent {     public function canSerialize(){         logArgs(args=arguments, from=getFunctionCalledName());         return true;     }     public function canDeserialize(){         logArgs(args=arguments, from=getFunctionCalledName());         return true;     }     public function serialize(){         logArgs(args=arguments, from=getFunctionCalledName());         return "SERIALISED";     }     public function deserialize(){         logArgs(args=arguments, from=getFunctionCalledName());         return "DESERIALISED";     }     private function logArgs(required struct args, required string from){         var dumpFile = getDirectoryFromPath(getCurrentTemplatePath()) & "dump_#from#.html";         if (fileExists(dumpFile)){             fileDelete(dumpFile);         }         writeDump(var=args, label=from, output=dumpFile, format="html");     } }
    This CFC needs to implement four methods:
    canSerialize() - indicates whether something can be serialised by the serialiser;
    canDeserialize() - indicates whether something can be deserialised by the serialiser;
    serialize() - the function used to serialise something
    deserialize() - the function used to deserialise something
    I'm being purposely vague on those functions for a reason. I'll get to that.
    The first [issue] in the implementation here is that for the custom serialisation to work, all four of those methods must be implemented in the serisalisation CFC. So common sense would dictate that a way to enforce that would be to require the CFC to implement an interface. That's what interfaces are for. Now I know people will argue the merit of having interfaces in CFML, but I don't really give a [monkey's] about that: CFML has interfaces, and this is what they're for. So when one specifies the serialiser in Application.cfc and it doesn't fulfil the interface requirement, it should error. Right then. When one specifies the inappropriate tool for the job. What instead happens is if the functions are omitted, one will get erratic behaviour in the application, through to outright errors when ColdFusion goes to call the functions and cannot find it. EG: if I have canSerialize() but no serialize() method, CF will error when it comes to serialise something:
    JSON serialization failure: Unable to serialize to JSON.
    Reason : The method serialize was not found in component C:/wwwroot/scribble/shared/git/blogExamples/coldfusion/CF11/customerserialiser/Serialiser .cfc.
    The error occurred inC:/wwwroot/scribble/shared/git/blogExamples/coldfusion/CF11/customerserialiser/testBasic.c fm: line 4
    2 : o = new Basic();
    3 :
    4 : serialised = serializeJson(o);5 : writeDump([serialised]);
    6 :
    Note that the error comes when I go to serialise something, not when ColdFusion is told about the serialiser in the first place. This is just lazy/thoughtless implementation on the part of Adobe. It invites bugs, and is just sloppy.
    The second [issue] follows immediately on from this.
    Given my sample serialiser above, I then run this test code to examine some stuff:
    o = new Basic(); serialised = serializeJson(o); writeDump([serialised]); deserialised = deserializeJson(serialised); writeDump([deserialised]);
    So all I'm doing is using (de)serializeJson() as a baseline to see how the functions work. here's Basic.cfc, btw:
    component { }
    And the test output:
    array
    1
    SERIALISED
    array
    1
    DESERIALISED
    This is as one would expect. OK, so that "works". But now... you'll've noted I am logging the arguments each of the serialisation methods receives, as I got.
    Here's the arguments passed to canSerialize():
    canSerialize - struct
    1
    XML
    My reaction to that is: "[WTH]?" Why is canSerialize() being passed the string "XML" when I'm trying to serialise an object of type Basic.cfc?
    Here's the docs for canSerialize() (from the page I linked to earlier):
    CanSerialize - Returns a boolean value and takes the "Accept Type" of the request as the argument. You can return true if you want the customserialzer to serialize the data to the passed argument type.
    Again, back to "[WTH]?" What's the "Accept type" of the request? And what the hell has the request got to do with a call to serializeJson()? You might think that "Accept type" references some HTTP header or something, but there is no "Accept type" header in the HTTP spec (that I can find: "Hypertext Transfer Protocol -- HTTP/1.1: 14 Header Field Definitions"). There's an "Accept" header (in this case: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"), and other ones like "Accept-Encoding", "Accept-Language"... but none of which contain a value of "XML". Even if there was... how would it be relevant to the question as to whether a Basic.cfc instance can be serialised? Raised as bug: 3750730.
    serialize() gets more sensible arguments:
    serialize - struct
    1
    https://www.blogger.com/nullserialize - component scribble.shared.git.blogExamples.coldfusion.CF11.customerserialiser.Basic
    2
    JSON
    So the first is the object to serialise (which surely should be part of the question canSerialize() is supposed to ask, and the format to serialise to. Cool.
    canDeserialize() is passed this:
    canDeserialize - struct
    1
    JSON
    I guess it's because it's being called from deserializeJson(), so it's legit to expect the input value is indeed JSON. Fair enough. (Note: I'm not actually passing it JSON, but that's beside the point here).
    And deserialize() is passed this:
    deserialize - struct
    1
    SERIALISED
    2
    JSON
    3
    [empty string]
    The first argument is the value to work on, and the second is the type of deserialisation to do. I have no idea what the third argument is for, and it's not mentioned directly or indirectly on that docs page. So dunno what the story is there.
    The next issue isn't a code-oriented one, but an implementation one: how the hell are we expected to work with this?
    The only way to work here is for each function to have a long array of IF/ELSEIF statements which somehow identify each object type that is serialisable, and then return true from canSerialise(), or in the case of serialize(), go ahead and do the serialisation. So this means this one CFC needs to know about everything which can be serialised in the entire application. Talk about a failure in "separation of concerns".
    You know the best way of determining if an object can be seriaslised? Ask it! Don't rely on something else needing to know. This can be achieved very easily in one of two ways:
    Check to see if the object implements a "Serializable" interface, which requires a serialize() method to exist.
    Or simply take the duck-typing approach: if a CFC implements a serialize() method: it can be serialised. By calling that method. Job done.
    Either approach would work fine, keeps things nicely encapsulated, and I see merits in both. And either make far more sense than Adobe's approach. Which is like something from the "OO Failures Special Needs" class.
    Deserialisation is trickier. Because it relies on somehow working out how to deserialise() an object. I'm not sure of the best approach here, but - again - how to deserialise something should be as close to the thing needing deserialisation as possible. IE: something in the serialised data itself which can be used to bootstrap the process.
    This could simply be a matter of specifying a CFC type at a known place in the serialised data. EG: Adobe stipulates that if the serialised data is JSON, and at the top level of the JSON is a key eg: type, and the value is an extant CFC... use that CFC's deserialize() method. Or it could look for an object which contains a type and a method, or whatever. But Adobe can specify a contract there.
    The only place I see a centralised CFC being relevant here is for a mechanism for handling serialised data that is neither a ColdFusion internal type, nor identifiable as above. In this case, perhaps they could provide a mechanism for a serialisation router, which basically has a bunch of routes (if/elseifs if need be) which contains logic as to how to work out how to deserialise the data. But it should not be the actual deserialiser, it should simply have the mechanism to find out how to do it. This is actually pretty much the same in operation as the deserialize() approach in the current implementation, but it doesn't need the canDeserialize() method (it can return false at the end of the routing), and it doesn't need to know about serialising. And also it's not the main mechanism to do the deserialisation, it's just the fall back if the prescribed approach hasn't been used.
    TBH, this still sounds a bit jerry-built, and I'm open for better suggestions. This is probably a well-trod subject in other languages, so it might be worth looking at how the likes of Groovy, Ruby or even PHP (eek!) achieve this.
    There's still another issue with the current approach. And this demonstrates that the Adobe guys don't actually work with either CFML applications or even modern websites. This approach only works for a single, stand-alone website (like how we might have done in 2001). What if I'm not in the business of building websites, but I build applications such as FW/1 or ColdBox or the like? Or any sort of "helper" application. They cannot use the current Adobe implementation of the customserializer. Why? Because the serialisation code needs to be in a website-specific CFC. There's no way for Luis to implement a custom serialiser in ColdBox (for example), and then have it work for someone using ColdBox. Because it relies on either editing Application.cfc to specify a different CFC, or editing the existing customSerializer CFC. Neither of which are very good solutions. This should have been immediately apparent to the Adobe engineer(s) implementing this stuff had they actually had any experience with modern web applications (which generally aren't just a single monolithic site, but an aggregation of various other sub applications). Equally, I know it's not a case of having thought about this and [I'm just missing something], because when I asked them the other day, at first they didn't even get what I was asking, but when I clarified were just like "oh yeah... um... err... yeah, you can't do that. We'll... have to... ah yeah". This has been raised as bug 3750731.
    So I declare the intent here valid, but the implementation to be more alpha- / pre-release- quality, not release-ready.
    Still: it could be easily deprecated and rework fairly easily. I've raised this as bug 3750732.
    Or am I missing something?
    Adam

    Yes, you can easily add additional questions to the Lookup.WebClient.Questions Lookup to allow some additional choices. We have added quite a few additional choices, we have noticed that removing them once people have selected them causes some errors.
    You can also customize the required number of questions to select when each user sets them up as well as the number required to be correct to reset the password, these options are in the System Configuration settings.
    If you need multi-language versions of the questions, you will also need to modify the appropriate language resource file in the xlWebApp.war file to provide the necessary translations for the values entered into the Lookup.

  • Interview questions?plz answer

    hi
    i have some interview questions;can anybody share with me?
    1.what is meant by static variable and static method with an example?what r the uses?;
    2.what r the uses of Interfaces over abstract class?
    3.Name two interfaces without method?
    4.what is meant by polymorphism?explain with an example?
    5.what is meant by deadlock?
    6.what is meant by time-slicing?
    7.how can u set input and output parameters using Callablestatement with an example?
    8.what is difference between throw and throws?

    hi
    i have some interview questions;can anybody share with
    me?
    1.what is meant by static variable and static method
    with an example?what r the uses?;A static variable changes rapidly. A static method changes methodically.
    2.what r the uses of Interfaces over abstract class?Interfaces used over abstract classes form a protective layer, insulating and encapsulating them from synchronization problems.
    3.Name two interfaces without method?Trick question. No interfaces have methods.
    4.what is meant by polymorphism?explain with an
    example?Men in Hawaii can marry more than one woman. Each wife does something different when the man asks her to give him some poi.
    5.what is meant by deadlock?Bob Marley's hair.
    6.what is meant by time-slicing?Time slicing is a technique for delaying an unpleasant task. A process can continue to put it off until later by slicing the remaining time in half.
    7.how can u set input and output parameters using
    Callablestatement with an example?You ought to know that. I'm not going to help you.
    8.what is difference between throw and throws?"Throw" is singular and used with one argument. "Throws" is plural and used with multiple arguments.
    Good luck.

  • 1760 Router Questions

    Essentially, I've been studying for the CCNA and I've decided to purchase some older equipment to set up in my house so I can get some additional practice with the IOS interface. I've been looking at 1760 routers on ebay, and it seems like a pretty good place to start as I would like to actually use the devices in my current LAN, rather than simply setting up a lab.
    My question is, could I take a 1760 and connect it to my cable modem, and then connect a switch (say a 2950 that I'll purchase a later date) to another interface? What add-in cards will I need to make this possible?
    Here's a graphic representation of what I'd like to do.
    If the 1760 isn't a good choice for this sort of setup, what would you reccomend? I'd prefer 100Mbit/sec capable routers if possible.
    Thanks for the help/suggestions.

    Taylor,
    if you have a VLAN capable switch and proper IOS support, you can configure PPPoE client on a subinterface hence you can use the 1760 (or any other router) to connect to the ISP and route between VLANs.
    This is my current setup:
    interface GigabitEthernet0/1
    no ip address
    duplex auto
    speed auto
    interface GigabitEthernet0/1.4
    encapsulation dot1Q 4
    ip pim dense-mode
    ip igmp query-interval 125
    pppoe enable group global
    pppoe-client dial-pool-number 9
    interface Dialer9
    mtu 1490
    bandwidth 4672
    bandwidth receive 480
    ip address negotiated
    ip nat outside
    ip virtual-reassembly in
    encapsulation ppp
    ip policy route-map RM-loop1
    dialer pool 9
    crypto map CM-1
    crypto ipsec client ezvpn witopia_IAD
    As you can see I use a subinterface to do PPPoE client and have the Dialer 9 interface receive the public IP address then I route traffic to other dubinterfaces. I used to do that on a 1751 nd on a 1721 this is now a 1921.
    You need to ensure the pppoe client on 803.1q subinterfaces is supported in the ios version you run and obviously that 803.1q subinterfaces are supported.
    You can do all of that in the cisco feature nav.
    Enjoy
    Fabio

  • DMVPN w/ Multicasting setup/questions

    Hello
    I have a lot of questions, so bare with me as i puke them out of my head.
    I have been doing some testing with DMVPN inconjuction with multicasting video (Hub and spoke, w/ no spoke to spoke). The test setup is using 2 cisco 2811 w/out the vpn module.  I understand the performance hit with not having the module. With that being said here are my questions.
    1. With encryption on both the HUB and spoke routers are using 90-97% cpu (8Mb multicast stream).  With encryption off, the Hub is around 60%, and spoke around 75%.  Here is where i'm confused.  If i send that same stream as a unicast stream, w/ encryption on, both the Hub and spoke are only using around 30-35% cpu.  Why is there so much more cpu need when its a multicast stream?
    2. In the current config i'm seeing input, throttles, and ignore errors on the Hub and spoke.  The Hub has these errors on the LAN interface, and the spoke has these errors on the WAN interface. All other interfaces are totally clean.  I have checked and there are no duplex or speed mismatches.  Any ideas?
    HUB:
    Current configuration : 1837 bytes
    version 12.4
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    hostname Hub
    boot-start-marker
    boot-end-marker
    logging message-counter syslog
    enable password
    no aaa new-model
    clock timezone Central -6
    dot11 syslog
    ip source-route
    ip cef
    no ip domain lookup
    ip name-server 8.8.8.8
    ip multicast-routing
    no ipv6 cef
    multilink bundle-name authenticated
    voice-card 0
    archive
    log config
      hidekeys
    interface Tunnel1
    bandwidth 100000
    ip address 192.168.11.1 255.255.255.0
    no ip redirects
    ip mtu 1400
    no ip next-hop-self eigrp 1
    ip pim sparse-mode
    ip nhrp map multicast dynamic
    ip nhrp network-id 1
    ip nhrp holdtime 450
    no ip route-cache cef
    ip tcp adjust-mss 1360
    no ip split-horizon eigrp 1
    delay 1000
    tunnel source FastEthernet0/0
    tunnel mode gre multipoint
    tunnel key 100000
    tunnel bandwidth transmit 100000
    tunnel bandwidth receive 100000
    interface FastEthernet0/0 (WAN)
    ip address 216.x.x.x 255.255.255.192
    ip pim sparse-mode
    load-interval 30
    duplex auto
    speed auto
    interface FastEthernet0/1 (LAN)
    ip address 128.112.64.5 255.255.248.0
    ip pim sparse-mode
    load-interval 30
    duplex auto
    speed auto
    router eigrp 1
    network 128.112.0.0
    network 192.168.11.0
    auto-summary
    ip forward-protocol nd
    ip route 0.0.0.0 0.0.0.0 216.x.x.x
    ip http server
    ip http authentication local
    ip http secure-server
    ip pim rp-address 128.112.64.5 10
    access-list 10 permit 239.10.0.0 0.0.255.255
    snmp-server community public RO
    Spoke:
    Current configuration : 1857 bytes
    version 12.4
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    hostname Spoke
    boot-start-marker
    boot-end-marker
    logging message-counter syslog
    enable password
    no aaa new-model
    clock timezone central -6
    dot11 syslog
    ip source-route
    ip cef
    no ip domain lookup
    ip multicast-routing
    no ipv6 cef
    multilink bundle-name authenticated
    voice-card 0
    archive
    log config
      hidekeys
    interface Tunnel1
    bandwidth 100000
    ip address 192.168.11.2 255.255.255.0
    no ip redirects
    ip mtu 1400
    ip pim sparse-mode
    ip nhrp map 192.168.11.1 216.x.x.x
    ip nhrp map multicast 216.x.x.x
    ip nhrp network-id 1
    ip nhrp holdtime 450
    ip nhrp nhs 192.168.11.1
    no ip route-cache cef
    ip tcp adjust-mss 1360
    no ip split-horizon eigrp 1
    delay 1000
    tunnel source FastEthernet0/0
    tunnel destination 216.x.x.x
    tunnel key 100000
    tunnel bandwidth transmit 100000
    tunnel bandwidth receive 100000
    interface FastEthernet0/0 (WAN)
    ip address 65.x.x.x 255.255.255.192
    ip pim sparse-mode
    load-interval 30
    duplex auto
    speed auto
    interface FastEthernet0/1  (LAN)
    ip address 128.124.64.1 255.255.248.0
    ip pim sparse-mode
    ip igmp join-group 239.10.10.10
    load-interval 30
    duplex auto
    speed auto
    router eigrp 1
    network 128.124.0.0
    network 192.168.11.0
    auto-summary
    ip forward-protocol nd
    ip route 0.0.0.0 0.0.0.0 65.x.x.x
    no ip http server
    no ip http secure-server
    ip pim rp-address 128.112.64.5 10
    access-list 10 permit 239.10.0.0 0.0.255.255
    snmp-server community public RO

    Joe,
    You ask the right question.
    CPU ultization = CPU consumed by processes + IO operations (in a huge simplification - CEF) 
    Typically when a packet is processed by router we expect it to be be processed by CEF, i.e. very fast.
    Packet is not processed by CEF:
    - when there is something missing to route the packet properly (think missing ARP/CAM entry) i.e. additional lookup needs to be done.
    - a feature requests that a packet is for processing/mangling
    - Packet is destined to the router
    (And several other, but those are the major ones).
    When a packet is recived, but cannot be processed by CEF, we "punt the packet to CPU" this in turn will cause the CPU for processes to go up.
    Now on the spoke this seems to be the problem:
    Spoke#show ip cef switching stati       Reason                          Drop       Punt  Punt2HostRP LES Packet destined for us             0       1723          0RP LES Encapsulation resource             0    1068275          0
    There were also some failures on one of the buffer outputs you've attached.
    Typically at this stage I would suggest:
    1) "Upgrade" the device to 15.0(1)M6 or 12.4(15)T (latest image in this branch) and check if the problem persists there.
    2) If it does, swing it by TAC. I don't see any obvious mistakes, but I'm just a guy in a chair same as you ;-)
    Marcin

  • Questions about Objects, pointers, and the memory that loves them

    Hey,
    This is all just a theoretical discussion so do understand that the code itself is not germane to the topic.
    I have been mulling over the whole object release/retain/copy thing and need to understand a bit more the real inner workings of the beast. The catalyst for this is the repetitional fervor that most books on the subject of Objective C have employed. Yet they all seem to fail in a complete explanation of the whys and wherefores so that one can determine on her own the correct implementation of this.
    Let's say I have an Object. For the fun of it it is an instance of NSObject and we'll call it myObject.
    When I "create" this object thusly:
    NSObject *myObject = [[NSObject alloc] init];
    What I, in fact get back is a pointer to the object in question, yes?
    So when I "seemingly" add this object to an array like:
    NSArray *myArray = [[NSArray alloc] initWithObject:myObject];
    What is actually placed in the array? is it another pointer to the original object created by myObject or is it a pointer to the pointer of myObject?
    The reason I ask this is because I have run into a situation where some previous instructions on the subject have caused errors. I was told that if I did something like this and then passed the array to a calling method that I could release this array and it would then be the responsibility of the calling method to handle the memory. Further more if I place an object into an array and then copy it into another object of the same type as the original then I could release the array and still have the reference to the first object in the second object. When I have done this I get unpredictable results, sometimes the original object is there and sometimes it isn't
    At what point should I release the array, after it is passed to the calling method (with the use of an autorelease) or when the class that it is encapsulated in is done?
    Sorry about the length of this but I can't believe that I would be the only one that would be helped by such a discussion.
    MM

    etresoft,
    Thanks for the detailed reply. I wish I could say that I wasn't still a bit confused by this. I thought I had this down after going through the lessons. It seems to not be working in practice the way that it works in theory.
    My current project is an example
    In a class I have declared a couple of ivars thusly:
    NSMutableString *source;
    NSMutableString *destination;
    @property (nonatomic, retain) NSMutableString *source;
    @property (nonatomic, retain) NSMutableString *destination;
    This is followed by the appropriate @synthesize directives.
    in the init method for my class I have the following:
    source = [[NSMutableString alloc] initWithString:@"customer"];
    destination = [[NSMutableString alloc] initWithString:@"home"];
    in a method triggered by a button click I have the following:
    if (sender == sourcePop){
    source = [sourcePop titleOfSelectedItem];
    }else{
    destination = [destinationPop titleOfSelectedItem];
    NSLog(@"SOURCE-%@", source);
    NSLog(@"DESTINATION-%@", destination);
    When I run the code and change the source selection the console reads the correct value for what is in the source popupbutton and "home" for the destination. If I then change the destination popupbutton I get a crash and nothing written to the console.
    Placing a breakpoint at the beginning of the "if" and running shows me that just before the crash the source ivar is reported as "out of scope." There are no release or autorelease statements for this ivar anywhere in the class. Yet if I change the line that sets the ivar to the value of the popupbutton to this:
    [source = [sourcePop titleOfSelectedItem] retain];
    The debugger will have the correct value for the ivar and when run normally there is no crash.
    I would assume that the problem is that the ivar is being released but I am not the one releasing it. Why does this behavior happen? Shouldn't the retain count still be 1 since the @property directive has it and there is no release in the code? Or is it that the statement that sets the ivar to the value of the popup really just setting it to the pointer and it is the popup that is somehow being released?
    Is there something else that I should be doing?
    MM

  • A language question, didn't find answer in spec.

    The question is, if I have a class defined as a private static member of another class, and it extends the outside class at the same time, can it access another private static member in the same class?
    The sample follows:
    public abstract class Main {
    private static class Runner extends Main {
    public void run(int i, int j) {
    run(i);
    private static synchronized void run(int i) {
    javac compiled it, but since Runner is a subclass of Main, it doesn't have the previllege to acess run( int ) in Main because it is a private member.
    I am confused...
    Thanks for any reply.

    Though I've not tried your situation specifically,
    everything inside of a class should have objectscope
    and visibility. Internal classes should be able to
    see back into the class they are encapsulated into.It's this vs access modifiers. Inner classes should
    be able to see back into the outer class, but
    apparently if the inner class extends the outer class
    (don't know why you'd do this), inner class (subclass)
    loses access since private members can't be seen by
    subclasses.
    I guess the access modifier takes precedence.Disregard this previous post.
    I think the call we are actually making is the static Main.run(int), not a member of Runner, therefore inheritance rules don't apply.
    I think this is what happens. Correct me if i'm wrong.
    Main.run(int)            What gets called
    static any access        Main.run(int) as a static method
    nonstatic private        Compile error
    nonstatic protected      Main.Runner.run(int) as an inherited method
    nonstatic public         Main.Runner.run(int) as an inherited method

  • Some question asked by interviewer to me

    Please look at some questions and post your most valuable thoughts.
    1). Can we create instance of interface or not if yes then how?
    Answer by me: I gave wrong answer.
    2). Java is comiled langauge or interpreted langauge if compiled langauge then which compiler.....?
    Answer by me: Java is compiled and interpreted langauge and javac compiler and java interpreter is used.
    3). Encapsulation and datahiding is same? if not so tell difference.
    Answer by me: In case of Encapsulation only data which donot contribute its essential characteristics will be hiding and only data hiding means all data will be hide.Thats the difference b/w these two.
    Interviewer also told me coding example of encapsulation. But I have not good example of that.
    4).Difference b/w awt and swing?
    Answer by me: Both awt and swing is used in applet but only difference b/w these two is- swing will give better look of label and buttons.
    5).What is syncronization and why we use syncronization in multithreading?
    Answer by me: Syncronization is used to prevent deadlock condition in multithreading.
    I was not the correct answer of "what is syncronization?"
    Please post your thoughts on any of 5 questions. I am also trying to findout answers.
    thanks
    Edited by: shobhit_onprob on Apr 18, 2009 5:05 AM

    shobhit_onprob wrote:
    Please look at some questions and post your most valuable thoughts.
    1). Can we create instance of interface or not if yes then how?
    Answer by me: I gave wrong answer.Instances of classes implementing an interface are considered instances of that interface ("is-a").
    2). Java is comiled langauge or interpreted langauge if compiled langauge then which compiler.....?
    Answer by me: Java is compiled and interpreted langauge and javac compiler and java interpreter is used.Java source code is compiled to byte code. That byte code can be executed in any way (the Java spec doesn't say how). It may be interpreted.
    3). Encapsulation and datahiding is same? if not so tell difference.
    Answer by me: In case of Encapsulation only data which donot contribute its essential characteristics will be hiding and only data hiding means all data will be hide.Thats the difference b/w these two.In my opinion Encapsulation is more than just data hiding. You can also encapsulate behaviour, for example.
    4).Difference b/w awt and swing?
    Answer by me: Both awt and swing is used in applet but only difference b/w these two is- swing will give better look of label and buttons.AWT is the "old" GUI toolkit that uses native controls of the environment it runs it.
    Swing is the "new" GUI toolkit that draws its controls in pure Java code and uses AWT as the underlying base.
    5).What is syncronization and why we use syncronization in multithreading?
    Answer by me: Syncronization is used to prevent deadlock condition in multithreading.
    I was not the correct answer of "what is syncronization?"No. synchronization can lead to deadlocks.
    synchronization is used to ensure that data is only accessed when it is in a consistent state.

  • 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.

Maybe you are looking for

  • Mac mini with Apple Mini Display to VGA adaptor

    Hello, I have just purchased a new i5 mac mini, and have started to use it with an HDMI TV. This is great, but I really want to go back to using just my VGA monitor, which is an LGFlatron W2243S. So, today, with the HDMI plugged in, I put a Apple Min

  • How To Play The Shuffle Thru A Boombox Or Stereo?

    I was wondering if it's possible to directly plug in the shuffle and play it using the speakers in my Sony boombox or through my stereo system - and what parts would be needed to do it?

  • External Drive not compatible with iMovie

    I just purchased a WD My Book 500gb drive to store home videos I'm editing in iMovie. The drive shows up in the event library with a yellow triangle with an exclamation mark in the center. If I try to drag events to the drive I get the following mess

  • Colored icons in finder

    using osx 10.6.8 on all my machines, but recently lent a MacPro for a project that has Lion. using that MacPro it's interesting to test Lion a bit, but one thing I am really wondering about: finder on osx 10.6.8 shows the icons of "home", "movies", "

  • Leave iPods and iPhones in iTunes "Devices" List even when disconnected.

    I could swear that I had seen some "Tips and Tricks" once that showed a way to leave iPods in the Device list of iTunes event when the device was not connected. I have multiple iPods and an iPhone, and I would like to manage their content without hav