LabVOOP article - Reusing Code by Inheritance

I've posted a new article this weekend to EXPRESSIONFLOW in an article series Introduction to Object-Oriented Programming in LabVIEW.
Reusing Code by Inheritance
The previous articles in the article series are:
Inheritance and Class Hierarchies in Object-Oriented Programming
Code Reuse with Interface Design and Composition
Introduction to Objects and Classes
Don't hesitate to comment the articles. All discussion is wellcome either here or on Expressionflow.
Tomi Maila

Ah sorry but thanks for pointing out! Please ignore the code below
"public abstract class FeatureSpaceBuilder(){",
I cannot re-edit it, but they should go like this:
public abstract class FeatureSpaceBuilder{
  //This method takes an article content(String), analyse the article and create its
  //feature space; the feature are stored in the method argument "space". 
  //Instead of returning a new FeatureSpace by the method itself,
  //I'd like to pass a FeatureSpace object to the method, and modify it by the method;
  //the reason is this method will be used iteratively, but eventually build only *one* FeatureSpace.
  // Consider given a corpus of 100 articles, this method will be called
  //100 times, building Features for each article, but store features in a
  // single FeatureSpace as for the whole corpus. So instead of creating
  // and returning then merging a new FeatureSpace each time, I just
  // pass the single FeatureSpace object to the method every iteration, and
  //modifies it.
  abstract void buildFeatureSpace(String article, FeatureSpace space);
public class FeatureSpaceBuilderImplA extends FeatureSpaceBuilder{
  public void buildFeatureSpace(String article, FeatureSpaceImplA space){
public class FeatureSpaceBuilderImplB extends FeatureSpaceBuilder{
  public void buildFeatureSpace(String article, FeatureSpaceImplB space){
}

Similar Messages

  • Migrating reuse code to lvlib files... namespace conversion leading to inability to find VIs?

    I am attempting to migrate my reuse code from llb files to directories, and in the process grouping code within lvlib files.  All of the reuse code resides within my user.lib directory (which is in the search path).  After this conversion process, which has resulted in VIs being in different physical locations and having their namespaces altered, my other code is unable to automatically find them?  Is there an automated method for telling my programs how to find the new reuse code.  If not, does anyone have any suggestions for where to start writing a program that could help with the conversion process?  Note, none of the VI names have changed, but of course their logical namespaces have.

    You can also manually change the VI search paths.
    http://zone.ni.com/reference/en-XX/help/371361B-01/lvhowto/adding_dir_vi_srch_path/
    Maybe you can temporarily add the new locations and go back to the defaults once you have saved all the VIs with the new paths.
    LabVIEW Champion . Do more with less code and in less time .

  • How to add my article in code gallery

    Hi All,
    Can anyone of you tell me how to add my article in code gallery. I want to post my article in code gallery, I tried to do that but I don't understand how to add my own screenshots, code and paragraphs.
    Looking forward for helpfuld answers.
    Thanks,
    Venkat

    Hi,
        Check this link , it's PPT how to contribute
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2f5d32b1-0c01-0010-4590-9ccd7d0cba4c
    for more details check this link
    ABAP Frequently Asked Questions
    Salil..

  • Entity framework code first inheritance table per type problem

    hello
    i am using ODP.NET version 11.2.0.3.20. i am trying to get entity framework code first to work. one problem i have encountered is with inheritance. i have a "table per type" inheritance scenario. i have 3 tables involved. the base table is called "S_PERIOD" which maps to the base "Period" class. i have a derived table called "S_SEASON_QUARTER" that maps to the derived "Quarter" class. And I have another derived table called "S_SEASON_PRICE_PERIOD" that maps to the derived "PriceBreak" class. for testing purposes i am trying to load all records. the problem is that every class instance ends up being of type "Quarter", which is incorrect. for whatever reason the provider thinks that every "S_PERIOD" record has a corresponding "S_SEASON_QUARTER" record. i took a look at the generated SQL and posted it down below. looking at this SQL it's clear to me why every object ends up being of type "Quarter". It looks like the provider is checking the "C2" field to determine the concrete type to instantiate. the problem however is that the "C2" field value provided by each derived table is ALWAYS equal to "1", which is a problem since this will result in the "case" statement always hitting the second "when" condition. does anyone have any idea how to fix this? thank you
    SELECT
    CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN '0X' WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN '0X0X' ELSE '0X1X' END AS "C1",
    CAST( "Extent1"."PERIOD_ID" AS number(10,0)) AS "C2",
    "Extent1"."START_DATE" AS "START_DATE",
    "Extent1"."END_DATE" AS "END_DATE",
    "Extent1"."NAME" AS "NAME",
    "Extent1"."TYPE_CODE" AS "TYPE_CODE",
    CAST( "Extent1"."CREATE_USER_ID" AS number(10,0)) AS "C3",
    "Extent1"."CREATE_DATE" AS "CREATE_DATE",
    CAST( "Extent1"."MODIFY_USER_ID" AS number(10,0)) AS "C4",
    "Extent1"."MODIFY_DATE" AS "MODIFY_DATE",
    CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN NULL WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN "Project1"."QUARTER_NAME" END AS "C5"
    FROM "DBO_SPACE_DEV"."S_PERIOD" "Extent1"
    LEFT OUTER JOIN (SELECT
         "Extent2"."QUARTER_NAME" AS "QUARTER_NAME",
         CAST( "Extent2"."QUARTER_ID" AS number(10,0)) AS "C1",
         1 AS "C2"
         FROM "DBO_SPACE_DEV"."S_SEASON_QUARTER" "Extent2" ) "Project1" ON ( CAST( "Extent1"."PERIOD_ID" AS number(10,0))) = "Project1"."C1"
    LEFT OUTER JOIN (SELECT
         CAST( "Extent3"."PRICE_PERIOD_ID" AS number(10,0)) AS "C1",
         1 AS "C2"
         FROM "DBO_SPACE_DEV"."S_SEASON_PRICE_PERIOD" "Extent3" ) "Project2" ON ( CAST( "Extent1"."PERIOD_ID" AS number(10,0))) = "Project2"."C1"
    Edited by: 997830 on Apr 3, 2013 8:40 AM

    An update:
    I tried again following this example to the letter:
    Using NuGet to Install and Configure Oracle Data Provider for .NET
    This time I used a console application as described in the example. Yes, I rebuilt the project after the NuGet install.
    I made the appropriate mods to App.config. I get the same error message as with the MVC example above.
    Does the ODP.Net driver really work with EF? If so, can anyone provide me with a working sample project?

  • EF6 Code first inheritance from relationship

    I need to create a TPH inheritance on an existing database using EF6 and Code first
    Table Person
    PersonId (Key)
    PersonName
    PersonTypeId (FK)
    Table PersonType:
    PersonTypeId (Key)
    Description
    Category
    The field PersonTypeId is the discriminator for the employees and managers, and the classes that I use are:
    class Person
    public string PersonId {get; set;}
    public string  TypeId {get; set;}
    public PersonType Type {get; set}
    class Employee : Person
    class Manager : Person
    I use the fluent API to create the relationship between Person and
    PersonType like that:
    HasOptional(e => e.Type).WithMany().HasForeignKey(f => f.TypeId);
    and it works as expected.
    Now, I need to Map the inherintance like that:
     m.Requires("Type.Category").HasValue("EMP");
    but it doesn't work because I receive an exception saying that the discriminator field doesn't exist.
    Any suggestions??

    I try to explain me better
    m.Requires("PersonTypeId").HasValue("EMP")
    It's ok, but it's not what I need 
    The mapping discriminator is not the PersonTypeId but the Category field that is in the class(or table) referred by PersonTypeId
    I have more than one values of PersonTypeId that has the same category (employee).
    If I choose your solution I need that PersonTypeId has more than one value
    Like that:
    m.Requires("PersonTypeId").HasValue("1").HasValue("2");
    but I know that there isn't this possiblity to have more than 1 value for a discriminator. Is it true?
    I try to explain me better
    m.Requires("PersonTypeId").HasValue("EMP")
    It's ok, but it's not what I need 
    The mapping discriminator is not the PersonTypeId but the Category field that is in the class(or table) referred by PersonTypeId
    I have more than one values of PersonTypeId that has the same category (employee).
    If I choose your solution I need that PersonTypeId has more than one value
    Like that:
    m.Requires("PersonTypeId").HasValue("1").HasValue("2");
    but I know that there isn't this possiblity to have more than 1 value for a discriminator. Is it true?

  • Reusing code within the same VI (when a sub-VI won't do)

    My last question here got awarded a kudos point "for being a great question", which is pretty embarrassing, because at my present skill level it's hard to envisage the time when I'll ever be anything other than a "taker" from this forum !  So here goes with a "dumb" question to try to put the record straight.
    My front panel has 17 groups of one button + three numeric indicators, that's quite a lot of front panel items and 8 of the groups have an enum indicator as well.  All of these items are also contolled by property nodes for visibility and/or "disabled".
    My program gathers all the data for these items into a Functional Global Variable array, and at end of the main loop it refreshes the properties and the values of all of these front panel items.  It could look unruly, but because of the similarity between the 17 groups the refresh of the front panel items all happens within a neat FOR loop (albeit with a 17-way CASE structure inside it) so at least these controls aren't sprawled out all over my block diagram.
    The only problem I have is that my program takes quite a few seconds to initialise and get the loop running, during which period the front panel shows garbage (well, maybe not garbage, maybe data related to the last time the program ran, which may have been a different context, so much better if not visible).
    But if I also ran the same "front panel refresh code" right after initialising (wiping) the data in my Functional Global, the result would be that all of these controls would be invisible or disabled, which is a much better place to start from.
    But do I have to put a completely separate copy of the loop onto my block diagram to get this effect ?
    Making a sub-VI is out of the question, because it's this VI's front panel I am working on.
    The word that describes (to me) what I want to do is "subroutine", but in LabVIEW "subroutine" seems to have a very specific meaning, a "stripped for speed" VI that won't touch any front panel anyway.
    Is this just a problem of my mindset ?  It's true that in my life by far the most code I wrote was assembler for 8-bit embedded micros, those applications were always strapped for memory.  At this stage of my career the balance won't be tipped however much high-level code I write (yes, I'm a dinosaur).  So I tend to fret about how big my compiled code will be.  Should I just put another copy of the loop (actually it's only the 76 "visible" property nodes I need) onto my block diagram and stop worrying about it ?
    Solved!
    Go to Solution.

    A number of comments.
    1) The title of Dinosaur is still up fro grabs with many of us in the running ( I as well used to play the game of "ICan write that charceter in X lines...")
    2) When you are doing a lot with the GUI, "Defer FP Updates (its a property of the FP to shut down screen updates, serach for that) may spped things up.
    3) I use a GUI controller very often in my apps. I posted about it here.
    4) If you chase down my tags I have a collection related to GUI performance.
    I'd put the code in a VI called from my GUI controler (that called your FG to get the info).
    Regarding memory
    When we used to depend on someone with a crochete hook and beads to make our memory, it was justified. Today, memory is cheap and using to save yourself time is just fine. When you worry about memory is when you find the code does not fit into 2 G anymore.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Anyone have tips on how to reuse code?

    I just discovered that we can't easily export pages from one application to another. HTML DB has been around long enough that I'm sure many of you have found ways to re-use your code. Can you give me any tips/hints/best-practices?

    That is fine for things like LOV queries, region queries, processes, etc, but a lof of times, there is a need to duplicate the page layout from one application to another. Yes, there is a procedure posted on this forum, but it is very cumbersome and error-prone.
    Hopefully the next release of Apex will have a streamlined way to copy pages across applications.

  • Is it advisable to use inheritance when reusing dialogs/frames?

    Hi!
    While working on a project, I've noticed that there are instances when I could reuse code by creating general forms (as dialogs or windows) and subclassing them. For example, I have this set of dialogs which have a similar function: each dialog has a table (or list) of objects and functions for adding, deleting and editing objects in this table. Do you think that it's good to use inheritance in this case? That is, I create a general AddEditDeleteDialog from which to subclass particular dialogs, AddEditDeleteObject1Dialog, AddEditDeleteObject2Dialog, ...
    Thanks!

    Yes, of course. But to what extent? Should I include
    layouting code, component initialization, event
    handling, etc in the superclass (AddEditDeleteDialog),
    or should I let the subclasses (AddEditDeleteObject1Dialog)
    handle that?Basically, whatever is the same in all the subclasses can be placed in the superclass. If there are differences, then you should place it in the subclasses.
    Things like event handling can be placed in the superclass, where each method in the event listener fires an abstract method in the superclass, which each of your subclasses implement to provide custom event handling.
    Component initialization can also be used in the superclass for whatever components are used in all of the subclasses. Subclasses can then add any components which are unique to them.
    You should also be aware that the purpose of inheritance is to add to the functionality of a class. If your subclass provides no extra abstract functionality then you should just use one class, and change some settings each time you need to use it for a different purpose. E.g. If your dialogs contain the same components, same actions etc but different text, then use just one class, and for each dialog, set the text for each of the components accordingly.
    There is no hard/fast rule for using inheritance and how to design an object hierarchy, and as my first programming teacher used to say "every programming problem can usually be solved in loads of different ways."

  • Maximize Code Reuse Between Windows Phone 8 and Windows 8(via Microsoft Dev Center)

    Win8 App Developers: Picked this up on the Microsoft Dev site..great tips for reusing code between your Windows 8 app and Windows Phone.
    Summary: In this section, we will help you make the right choices to maximize code reuse in your apps. As a developer, you want to streamline your development and make maintaining your apps as efficient as possible. By working smarter, you give yourself more time to develop more apps and fill the marketplace with your creations. When building an app for Windows Phone 8 and Windows 8, you should look for opportunities to share code, designs, and assets as much as possible so that you maximize the return on your investment. This section describes the sharing techniques that you can use when building you app for both platforms.Read full article
    LenovoDev.com Manager

    Very useful! Thank you!
    Jonas
    Microsoft MVP: Windows Consumer Expert
    Yoga Tablet 2 10 || ThinkPad X1 Carbon (20A7007MPH) || ThinkPad Helix (3698-6EU) || IdeaCentre B540
    Twitter: @jonashendrickx

  • Article master - bar codes

    Hi All,
    i want to delete bar code value for Generic  and  variant articles.
    I Have to delete more 2000 article , i can delete bar code in mm42 manually . but it is takeing so much time.
    but we can't use BDC or lsmw . variant article bar code values got wrong bar code and right bar code ,
    we have to delete wrong bar code and click right bar code and we have to save it in mm42.
    can any body please let me know , how to delete bar codes.
    Thanks,
    venu.

    Venu,
    I think you can write a simple program using bapi BAPI_MATERIAL_MAINTAINDATA_RT, here you can pass article info with dummy EANs in table parameter INTERNATIONALARTNOS.
    -Chenna.

  • How  to reuse common code across multiple work repositories

    Hi Experts,
    I have a ruqirements from our customer side. we have a one master repository attached with three work repositories(wk1,wk2,2k3). Customer want to place some common code into wk1 workrepository and want to reuse across multiple workrepositories(wk2,wk3).
    Generally we can reuse code in same work repositories like knowmodules and interfaces.
    Is it possible to use across mutiple workrepositories?
    Thanks in Advance
    Siri

    You can't hare the same instance of the code across multiple work repositories. You have to have a seperate instance in each work repository. However you can manage it as if it was shared through ODI's versioning capability i.e. all changes to the common code are only ever made in one work repository i.e. Wk1 and then deployed to the other 2 which is as simple as getting the latest version from the Master repository. You could even set up security in Wk2 and Wk3 to make sure that your developers/users do not have permission to edit the common code in those repositories.

  • Multiple Inheritance

    Hello,
    I have been programming Java for last year,
    evolved in quite some skills with it, and
    really think it is great...
    However, I was shocked to find out that there
    is no multiple inheritance feature.
    I know it is rare, and my case proves it
    (1 year now, I never needed it)
    HOWEVER, when one needs multiple inheritance,
    then they really do need it.
    I have interfaces which I would like implemented
    in their respective class (ie ISomething be
    implemented in CSomething), then some classes
    I need to implement many of those interfaces...
    Now I am forced to have those classes extend
    multiple interfaces, and duplicate the interface
    implementation code inside each of them.
    I dont mind a little bit of copy/paste, nor
    do I care about the compiled classes being
    slightly bigger, BUT the problem is that
    when I need to change some behaviour in those
    interfaces, in the near (or far) future, I will
    have their implementation scattered in many
    classes... This is dangerously error prone and
    not proffesional at all... And I do not think
    that including multiple inheritance in the language
    could be more error prone than this...
    I think the Java team does a 100% perfect brilliant
    job, but at this specific point, they "over-tried"
    to "protect" the programmers from themselves...
    Well, thats all,
    I think some next version of Java should support
    multiple inheritance. And the Java "warning" could be :
    "if you havent missed it till now, then you probably
    do not need anyway, so do not bother using it just
    because it exists"
    Thanks for reading my thoughts,
    Dimitris

    Personally I never need multiple inheritance of code and I try to avoid inheritance of code whenever possible. A common mistake in OO is too use inheritance as a way of reusing code. Code reuse is much easier, cleaner and more powerful by using composition instead. Only use inheritance for polymorhism (to use multiple implementations for the same interface). An example:
    interface A {
      void ma();
      void maa();
    interface B {
      void mb();
    class C implements A, B {
      private A a;
      private A c;
      private B b;
      public void ma() {
        a.ma();
      public void maa() {
        c.maa();
      public void mb() {
        b.mb();
    }This is much more powerful than code reuse through inheritance. In this example I use one method from 'a' and one method from 'c' when I implement interface A. I can change the value of 'a', 'b' and 'c' during runtime, and I dont have to reuse all the code in 'a' and 'b', I can select which code to reuse. This is the power of composition and interfaces. Note that I only access 'a', 'b' and 'c' through the interfaces A and B, never directly through their implementations.
    I would recommend you to look at your design and start to think about interfaces and inheritance, not about code reuse though inheritance.

  • Delegation vs. Inheritance UML examples

    Hello,
    I'm currently trying to look into the differences between inheritance and delegation in java.
    From the articles I've read I think I understand the difference - having read their explanations and java code (that inheritance is the static placement of superclasses above subclasses at compile-time, which is rigid, whilst allowing for the inheritance of attributes/operations... yet delegation involves dynamically REFERENCING a subclass' superclass for methods, which means the referenced delegate can be changed in the future...)
    However, I'd be interested in looking at some examples with proper UML diagrams, but can't find anything on the internet...?
    Any got anything for a beginner who only just this morning began reading up on delegation vs. inheritance?
    Thanks!
    Sarah.

    Here would be my 2 cents worth. One nice (irritating?) thing about OOA/OOD is that there are many relatively correct design solutions to a given problem. What makes one better than another is usually not functional requirements (like compute a value), but non-functional requirements (like performance, security, extensibility...)
    Anyway, consider that you are designing the game of Scrabble. Each player has a tray that can hold 0-7 tiles. The main purpose of the tray is to hold a collection of letter tiles. Your first impulse might be to use inheritance. Rack is a subclass of ArrayList.
    | ArrayList | Pick your favorite collection class.....
    ---- (this is supposed to be a triangle)
    |
    |
    | Rack |
    Translated to Java
    public class Rack extends ArrayList
    The disadvantage is that you are exposing the entire interface of an ArrayList through your Rack. That may or may not be desirable. Say the customer calls up and wants to now have super scrabble, and you need to use a HashMap to look up data, then changing the super class could break alot of your code.
    Alternatively, we could hide all knowledge of how letters are stored (or even if they are stored). We only know that we can put letters in, and take them out and look at them. In the background we will delegate responsibility for storing these letters to some other class. Our UML might look like:
    --------------- Stores 0..7 --------------------
    | Rack | ____________________| Letters |
    How I store those letters is private. The implementor of Rack can
    use any data structure they want. The Java translation might be:
    public class Rack {
    private List<Letter> stores;
    Remember also that UML is just a tool to help you communicate design concepts within your team. If you spend more time on syntax than you do on actual design, it is no longer a help, it is a hinderance.
    Hopefully I have not confused you more....

  • Why to use inheritance when import is sufficient

    The import directive tells the compiler where to look for the class definitions when it comes upon a class that it cannot find in the default java.lang package. After an import statement has been included in our program we can use the methods related to that class as required and we are not required to give the fully qualified names.
    In inheritance we extend a base class into a derived class so that the features and methods of the base class are available in the derived class which facilitates reusability. As per my understanding the same thing is facilitated by import statements. If it is so, why are we using inheritance if it can be done with the use of import statements?

    Import statements and inheritance are completely different things.
    Import statements tell the compiler how to expand brief class names into fully-qualified class names. It has nothing to do with the functionality of the code.
    Inheritance changes the identification and functionality of the classes, and thus the functionality of the code.
    Maybe you're really thinking about composition/delegation vs. inheritance. Composition is when a class has another class as a part of it, and delegation is when the class sends some of its work to the other class. You can have an object-oriented system without inheritance of implementations, using composition instead.

  • Best approach to dealing with someone else's sphagetti code with no documentat​ion

    Hello LabVIEW gurus,
    I am just given a few software tools to add functionality and rewrite, each of which is a big spaghetti mess and each tool has 100+ vis all sphagetti, these tools control a very complex machine talking via seria, parallel, ethernet, 485 etc. and there is barely any documentation of the logic or the implemetation of the source code / what the subvis do. 
    what would be my best approach to understand this mess and recreate it in a structured way faster. it has lot of old sequence structures and just plain bad style of programming.
    any help is highly appreciated
    Thanks all

    And Do not forget about using the VI Analyzer TK!  It can reveal several obvious sources to clarify code that "Stinks" A lot of skull sweat went into that framework and it has signifigant value!
    Norbert_B wrote:
    If your task is only to ADD things, you might be interested in Steve's recommendation here.
    Norbert
    (Inside joke ahead)
    Ah, That explains the TDMS File Viewer!
    Spoiler (Highlight to read)
    You really should run that through the VIA....:smileymad
    You really should run that through the VIA....:smileymad
    Spoiler (Highlight to read)
    It can be done fairly quick
    It can be done fairly quick
    Spoiler (Highlight to read)
    How do you unspoiler?  Ah well  I'll hope a moderator can leave only the first comment "spoiled"
    How do you unspoiler?  Ah well  I'll hope a moderator can leave only the first comment "spoiled"
    Spoiler (Highlight to read)
    Note the quote from the link "The Code we inherited might have been "richly obfuscated."" "richly Obfuscaed code was a code review term used for code written by your boss... The VIA would call it something else.
    Note the quote from the link "The Code we inherited might have been "richly obfuscated."" "richly Obfuscaed code was a code review term used for code written by your boss... The VIA would call it something else.
    Jeff

Maybe you are looking for

  • JAVASCRIPT ISSUE (i realize this is a java forum not J.S.) URGENT!

    Hello, First off I realize this is a java forum and not Javascript so if you are do not know Javascript ignore this thread. I posted it here because Ive used this before and help is often prompt. However, If anyone out there knows javascript would yo

  • How to use Min function to get FileName into a Variable

    I was wondering how to use MIN function in Evaluate variable in package to get the first file name from the list(Datastore) With reference to Merging Flat Files into a single file Post number-4 Thanx

  • Why would 32-bit Flash Player be installed on a new 64-bit computer?

    Hi, I've a 5-day old Windows 8.1 computer using Internet Explorer 11. The Control Panel has an entry that reads, "Flash Player (32 Bit)". When I click on it and go to "Advanced", the update options are all greyed-out - though next to the CHECK NOW bo

  • Error on export, ultra hi-rez image / project

    I'm working on an HD+ project (ProRes4444, footage shot at 5K). And I'm doing tests with still images--importing them at a huge frame size. I'm not being naive. I genuinely need to get huge screen size, as it will be projected as such... and I wish t

  • WLS10.3 and wssp1.1 policies support

    Hi, I try to use SAML policies in OSB 10.3 ( ALSB). But the OSB only supports the wssp1.1 policies and the web services I try to call in the OSB are deployed on a wls 10.3 server which supports the wssp1.2 policies Can I use the wss1.1 policies on a