User Profile

Collapse

Profile Sidebar

Collapse
jhumelsine
jhumelsine
Last Activity: Aug 5 '10, 07:04 PM
Joined: May 5 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jhumelsine
    replied to trying to understand C string pointers
    in C
    It's been a long time since I coded in C. I'm mostly in C++ now, so please take this comment with a grain of salt.

    I think that C passes by value, so name2 = NULL may only be setting parameter to NULL, not the original name argument.

    If that's the case, then name is still pointing to the same block of memory, whether it's free or not. You might be able to confirm this by printing the address of name (&name, I think),...
    See more | Go to post

    Leave a comment:


  • jhumelsine
    replied to How to define a Grammar for a Language
    What you're listing looks just like the core idea for the pumping lemma from automata theory, except they use uvw instead of abc, and uvw can be sequences of any length.

    Can you provide more detail? I'm not sure what you're really trying to do.

    In addition to more description, can you provide some examples of what's in the language. I think it may be:

    ac
    abc
    abbc
    abbbc
    abb...bbc...
    See more | Go to post

    Leave a comment:


  • I looked over the paper. Wow. The word "obfuscate" comes to mind.

    I don't know much about FP Trees, but I did find a link that might help: http://www.csc.liv.ac.uk/~frans/KDD/.../fpGrowth.html

    I think it might be close to what you're looking for. It includes links to a Java implemenation, which should help, if what the link is talking about is anywhere close to what you're working upon.
    ...
    See more | Go to post

    Leave a comment:


  • Consider Chain of Responsibility

    Here's another possibility of thinking about this problem. Instead of using template method, which depends upon inheritence, let's try chain-of-responsibility (CoR), which is based upon delegation, and does so by forming a chain of delegates.

    Chain of Responsibility can be found at: http://en.wikipedia.org/wiki/Chain-o...bility_pattern

    Rather than trying to type...
    See more | Go to post

    Leave a comment:


  • jhumelsine
    replied to How can an object ask to be deleted?
    in C
    As simple as it sounds, I don’t think you can directly do what you want. For example, an object cannot commit suicide, i.e., it can’t delete itself. What would happen to the thread?

    For much the same reason, your component cannot ask its container to delete it. The thread would be going from the component to the container where the container would delete it and then back to … what?

    Asking another object...
    See more | Go to post

    Leave a comment:


  • I think it's a matter of convenience and flexibility. With a static class, I think just about every attribute in the class needs to be static as well. I don't tend us use static classes, except for a place to store methods, so I'm not 100% on this.

    With Singleton, you don't need to make every attribute static, so it may fit better with the rest of your classes, since it's really an object just like any other object, but only with the...
    See more | Go to post

    Leave a comment:


  • jhumelsine
    replied to The ideal pattern
    Use Factory Method

    Use Factory Method for this. You'll still have the if/else in your code, but it will be in a better spot.

    Create a static method in Server called create. It will look something like the following:
    Code:
    public static Server create(ServerInfo info)
    {[INDENT]if (info == FTP)[INDENT]return new FTPServer;[/INDENT]
    else if (info == SQL)[INDENT]return new SQLServer;[/INDENT][/INDENT]
    }
    Your implementation becomes:
    ...
    See more | Go to post
    Last edited by Frinavale; May 5 '10, 08:57 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

    Leave a comment:


  • Sorry about the formatting. That was my first post. There's a mistake in the getHours() method. The final } should be before the else, not after it....
    See more | Go to post

    Leave a comment:


  • Anders,

    I'm not sure I understand exactly what you are trying to do, but I think the Template Method design pattern may be what you're looking for. http://en.wikipedia.org/wiki/Template_method_pattern

    You still use polymorphism, but it's done so in a more privately.

    Provide an implemenation at Service for getHours. It would be something like the following:

    public int getHours() {
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...