Results 1 to 10 of 10

Thread: Automation of Interface from Class?

  1. #1

    Thread Starter
    New Member piboss's Avatar
    Join Date
    Apr 2011
    Location
    Cleveland, Ohio, USA
    Posts
    5

    Automation of Interface from Class?

    How do we automate the process of deriving an Interface from our already-designed class?

    In other words, I wrote in completion my entire class and now desire to automatically construct its interface. EG: Say my class's filename is "Car.vb", I now desire "ICar.vb" derived from the class "Car" that I've written.

    Thanks; Glenn

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Automation of Interface from Class?

    That functionality is available in C# but not in VB.

  3. #3
    Fanatic Member BlindSniper's Avatar
    Join Date
    Jan 2011
    Location
    South Africa
    Posts
    865

    Re: Automation of Interface from Class?

    you could perhaps just write something that parses an Interface out, although It sounds like you will be fixing many errors.

  4. #4
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Automation of Interface from Class?

    You can download a free trial version of ReSharper. Once installed, rightclick your class name, choose Refactor - Extract Interface. Then you can choose the name of your interface (ICar would be the default if Car was the class name), where to place it, which members to put in the interface, etc. ReSharper's VB support is a little weak in my opinion (at least compared to C# support) but I just tried it and extracting an interface is definitely available for VB.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Automation of Interface from Class?

    I can certainly recommend ReSharper if you do want help doing this sort of thing. I've been using it for a couple of years now and it is invaluable. For a professional, the purchase price is an investment because you'll soon recoup it in increased productivity.

  6. #6
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Automation of Interface from Class?

    Quote Originally Posted by jmcilhinney View Post
    I can certainly recommend ReSharper if you do want help doing this sort of thing. I've been using it for a couple of years now and it is invaluable. For a professional, the purchase price is an investment because you'll soon recoup it in increased productivity.
    Can't agree more. It's a great tool. I use it at work but when I'm programming at home in my free time I don't have it (it's a little expensive as a hobby...) and I miss it a lot. It just does so many things and it does them so well. In fact, it even taught me LINQ because it suggests replacing some complicated loop with a single LINQ expression - awesome! I'd just let it replace the loop by LINQ, read it, undo it again and see how it works and after a few times I skipped the loop and just wrote LINQ the first time.

    The only drawback is that, compared to C#, the VB support is quite weak. Most features (such as the LINQ suggestions) don't work in VB. Luckily most refactorings (such as extracting an interface) are available.

  7. #7

    Thread Starter
    New Member piboss's Avatar
    Join Date
    Apr 2011
    Location
    Cleveland, Ohio, USA
    Posts
    5

    Re: Automation of Interface from Class?

    Thanks Nick. Seeing that you and other experienced programmers are advocating the use of Resharper for the automation process I';m putting it on my list. On the note of C# in comparison with VB, tell me your perspective...

    I am not concerned with efficiency, my primary as well as ultimate goal is to be able to realize my innovative visions as quickly and as simple as possible. I will save the efficient and performance yielding code tasks for the production department programmers. What, if any, would be the benefit of me migrating/learning better Visual C#?

  8. #8

    Thread Starter
    New Member piboss's Avatar
    Join Date
    Apr 2011
    Location
    Cleveland, Ohio, USA
    Posts
    5

    Re: Automation of Interface from Class?

    Quote Originally Posted by jmcilhinney View Post
    I can certainly recommend ReSharper if you do want help doing this sort of thing. I've been using it for a couple of years now and it is invaluable. For a professional, the purchase price is an investment because you'll soon recoup it in increased productivity.
    Thanks, I'm now DL'g ReSharper

  9. #9
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Automation of Interface from Class?

    Resharper is a must-have.

    RE: Should I learn VB .NET or C#?

    The short answer is you should learn both, maybe specializing in one. If you were to draw the languages in a Venn Diagram, the places where they don't overlap are very small and the only language of the two that can do something useful the other can only approximate with more work is C#: pointer arithmetic is much faster than VB .NET's approximation and the only reason to use it is in rare performance-sensitive scenarios.

    You'll find more examples and more books that use C# than VB. More people that work on how to write code the "right" way use C# than VB. But it's mostly because of an irrational distaste of BASIC-derived languages than any real problems with VB. If you are a .NET developer, you should know C#, but it's OK if you prefer VB.

    Now for the long answer, which attempts to explain more.

    There's two ways to program. One methodology always asks, "Am I implementing the best thing?" The other methodology always asks, "Does it work?" The difference is subtle, but key to understanding why VB has a bad reputation.

    The developer who asks, "Does it work?" is only interested in checking boxes off of a requirements list. "Is it slow?" only matters if a requirement is "Make it fast." "Does it waste memory?" is only important if a requirement is "Be efficient." "Does it have bugs?" is only tested by casually walking through a script. These developers are famous for finishing a job quickly. They also often produce a rat's nest of unmaintainable code. Their programs often crash if you click the wrong button and usually don't work if you forget the order you're supposed to perform tasks. Much money is spent fixing and adjusting for thier finished product.

    The developer who asks "Am I implementing the best thing?" cares about the overall quality of his work. When he is done, he criticizes his work. "Should it be faster?" "Should it use less memory?" "What happens if I click 'Sell' with no item selected?" These developers often take a long time to finish their job. But what they produce is maintainable and robust. Little money is spent once they are finished. These developers tend to look down on the "Does it work?" developers.

    The best developer is somewhere in the middle; she finishes her job on schedule and produces robust software that is relatively easy to maintain. She may have had to make some bad choices to meet the schedule, but they were conscious decisions rather than copy/paste accidents.

    A programming language can target users at any point along this continuum. Here's how some popular languages stack up:
    • PHP is a relatively unstructured language that emphasizes speed of development over sound practices.
    • HTML sits in a strange universe where neither "good code" nor "finished on time" is attainable.
    • C's lack of high-level abstractions makes it useful for a developer to implement "the right thing" at all costs. However, developers have the freedom to make things work with no regards towards good practices.
    • Java's API enforces the understanding and use of many OOP design patterns; it leans towards the "make it right" side.
    • BASIC has a small vocabulary of keywords and few language structure elements; it's focused towards the "make it work" mentality.

    A language that focuses on "make it work" isn't always bad. With discipline, it's possible to write high-quality PHP or BASIC. With apathy, it's possible to write unmaintainable Java. But it's harder to write good BASIC than good Java and vice versa.

    I left out C# and VB on purpose; now I have the background for the differences.

    C#'s direct influence was Java, which was influenced by C++, which was influenced by C. This gives it a strong design pedigree in "do it right" design. However, C# seems to have the philosophy that Java took "do it right" too far and made simple things difficult. C# relaxes the focus and the result is a language that's closer to C/C++ in spirit: you can still easily do things the right way, but you're free to stray from the path if needed.

    VB .NET's direct influence was VB6, and that one deserves its own paragraph. I'll come back to .NET.

    VB6 is a hybrid of BASIC and Turbo Pascal in my opinion. These are both venerable languages. MS decided to take the structure of Turbo Pascal and combine it with the focus on rapid development of BASIC. If Java overemphasized "do it right", perhaps VB6 overemphasized "make it work". VB6 was really easy to pick up, and it was easy to get from zero to working software in a day. Unfortunately it didn't place much emphasis on good design and not many materials were provided to help new developers learn good practices. Disciplined developers can produce great works in VB6; they were outnumbered by amateurs who produced several generations of horrors upon companies. It's hard to justify your salary as a "make it work" programmer when the hiring manager sees a fresh college grad that promises he can finish early. There's your source of animosity: there's a view that VB6 brought about a crop of developers that "poisoned the well" for good programmers. Whether that's true or not, it *is* provable that many projects wasted millions of dollars that might have been saved by hiring more experienced developers. If VB6 didn't make it easier for the hacks to show talent, perhaps we'd have more respect.

    Anyway, VB .NET already got a strike against it for being a descendant of VB6. However, it's closer to C# than it is to VB6. But MS has thrown some bones out to the VB6 developers. There's several libraries easily available to VB .NET that make VB .NET seem familiar to VB6. A few language features unique to VB .NET are warts from VB6 carried forward. Still, I think VB .NET doesn't deserve the bad reputation it gets: if you ignore the "make it work" parts of the language you're left with something that doesn't get in the way of "do it right". However, many developers have been in C-style languages for years now, and VB .NET's non-C-style syntax is the final nail in the coffin for these developers. Besides, if you know C# and want to learn something new, why learn another .NET language?

    It's important to be able to read a C-style language. Many good software engineering books use C, C++, or Java as their language. Most .NET books use C# as their language. Most code examples online are in C# or Java. Lots of exciting work in language design can be found in Ruby and Python, two C-style languages. There are no VB deriviatives of note in modern software engineering research.

    If I love C-style languages so much, why do I write so much about VB on forums? VB .NET was my first job. It'll always have a special place in my heart. I think it's as good as C#, but I think its syntax is going to continue to cause it to be shunned by a C-centric development community. MS probably should have made a VB7 and left C# as the only .NET language. That would have made a clear division between "I want it fast, I don't care" and "I'd like to design a long-lasting framework". I think the best thing they could have done for VB .NET is picked a different name to remove the baggage that VB6's reputation has. Even then, I don't think the C-style guys would have accepted it.

  10. #10

    Thread Starter
    New Member piboss's Avatar
    Join Date
    Apr 2011
    Location
    Cleveland, Ohio, USA
    Posts
    5

    Re: Automation of Interface from Class?

    Thanks! I have been programming since '81 and your synopsis of our programming history to date is well appreciated as well as sound (from my perspective).

    I was one who started with Basica I think it was, I used a TI-99 with my cassette deck as my hard drive and TV as my screen. I had learned Assembly, Fortran, Cobol and Basic through to Visual Basic (I still have a set of unopened VB in my back room along VB6 3.5" disks, etc) but I never saw a reason to learn, or become proficient in the use of C, C++, or/and Visual C++, though I have Visual Studio 10. In the late 90's I spent about a year lolly-gagging around with Boreland's C++ on the side but for my purpose ("laying-down visions/innovative ideas) you've solidified my feelings that Visual Basic.NET suits me perfect! I love laying down sound, cordial, Object Oriented code that, not only others can later read and update, but that I can as well and Visual Basic.NET provides me this ability upon the motivation.

    Thanks! I took in all you wrote and enjoyed your style...

    Glenn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width