Page 8 of 14 FirstFirst ... 567891011 ... LastLast
Results 71 to 80 of 132
  1. #71

    Default

    Quote Originally Posted by MarkCuering View Post
    one line man gihapon to akong gi pang edit ila lang gi butang sa nested if statements., if it requires you to include try-catch-throw statements, better not to use ternary operators also.

    huh? one-line ifs na gi butang sa nested if statements?

    di ba na contradictory? mao gani one-life ifs, unya inside nested na nuon?

    naglibog na jud ko unsa imo point..

  2. #72

    Smile

    Quote Originally Posted by bluedes View Post
    semantically, there's no difference between the two.. this practice is just to help the compiler spot an error if in case only 1 equals sign was written


    if ( variable == TRUE )

    when mistakenly written as

    if ( variable = TRUE )

    will not trigger a compiler error even though logically, error na na..


    but kung balehon nimo..

    if ( TRUE == variable )

    a mistake like this

    if ( TRUE = variable )

    will be spotted by compiler right away..
    I like this logic... at first I was thinking it's not useful and still the same with the first IF statement but as I read over I found it good to implement. I often stumble a mistake that you mentioned. Thanks for this.

  3. #73

    Default

    ternary operators are useful for simple one liner statement.

    i saw some ternary operator being abused in a php code it was hell, tracing it lol



    i use watch if im debugging multiple functions, that are using a common variable name inside.

    Code:
    func1() {
     x = blah blah
    }
    
    func2() {
     x = blah blah 2
    }
    another design pattern i see useful is a class factory.

    i dont want to talk about it cuz google does a better job LOL.

  4. #74

    Default

    Quote Originally Posted by silent-kill View Post
    ternary operators are useful for simple one liner statement.

    i saw some ternary operator being abused in a php code it was hell, tracing it lol



    i use watch if im debugging multiple functions, that are using a common variable name inside.

    Code:
    func1() {
     x = blah blah
    }
    
    func2() {
     x = blah blah 2
    }
    another design pattern i see useful is a class factory.

    i dont want to talk about it cuz google does a better job LOL.
    class factory =? singleton? or the one where the class also has a mechanism for handling its instances...?

    either ways, yes, I also use those models.. it's very nice..

  5. #75

    Default

    singleton is a pattern used to insure you only have 1 instance of that class for the entire lifespan of the assembly.

    as for the class factory or factory design pattern.
    Factory method pattern - Wikipedia, the free encyclopedia

  6. #76

    Default

    Quote Originally Posted by bluedes View Post
    class factory =? singleton? or the one where the class also has a mechanism for handling its instances...?

    either ways, yes, I also use those models.. it's very nice..
    Nope. A factory is an object that instantiates various classes, although the factory itself can be implemented as a singleton.

    Analogy: a singleton is like a static variable in C. All instances of a singleton would refer to only one object. It's like a global variable in C (in fact, most people use singletons as replacements for globals).

  7. #77

    Default

    Problem: A thread instantiate a singleton, while it's not done instantiating, another thread instantiate the same singleton class. Now they are two instances.

    So how do you ensure single instance in a Singleton in a multi-threaded environment?

  8. #78

    Default

    is this with respect to JAVA?

  9. #79

    Default

    Quote Originally Posted by MarkCuering View Post
    is this with respect to JAVA?
    applicable to any language.

  10. #80

    Default

    in C++/C# we have a volatile keyword: (can be useful across multiple domain under multithreaded application.)

    The volatile keyword indicates that a field can be modified in the program by something such as the operating system, the hardware, or a concurrently executing thread. The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock statement to serialize access. Using the volatile modifier ensures that one thread retrieves the most up-to-date value written by another thread.


    if single domain only, locking/synchronization with static initialization approach is enough I guess.

    there are variety of threading under managed/unmanaged world... If the implementation uses a ThreadPool under managed world, one can apply delay/sleep under Running State of the thread.

Page 8 of 14 FirstFirst ... 567891011 ... LastLast

Similar Threads

 
  1. what's the best and most practical NEGOSYO today?????
    By fratbaxxx in forum Business, Finance & Economics Discussions
    Replies: 166
    Last Post: 10-09-2014, 01:31 PM
  2. Looking For: Pattern makers, Seamstresses and Tailors
    By kamikaze_007 in forum Jobs
    Replies: 5
    Last Post: 06-02-2013, 10:47 AM
  3. Replies: 0
    Last Post: 09-14-2007, 10:14 AM
  4. Replies: 0
    Last Post: 06-21-2007, 11:01 AM
  5. Bad design and coding practices (antipatterns)
    By cmontoya in forum Programming
    Replies: 8
    Last Post: 01-05-2006, 06:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top