Search Results

Search found 50594 results on 2024 pages for 'dynamic class loaders'.

Page 7/2024 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Class or Dictionary

    - by user2038134
    I want to create a immutable Scale class in C#. public sealed class Scale { string _Name; string _Description; SomeOrderedCollection _ScaleValueDefinitions; Unit _Unit // properties .... // methods ContainsValue(double value) .... // constructors // all parameters except scalevaluedefinitions are optional // for a Scale to be useful atleast 1 ScaleValueDefinition should exist public Scale(string name, string description, SomeOrderedCollection scaleValueDefinitions, unit) { /* initialize */} } so first a ScaleValueDefinition should be represented by to values: Value (double) Definition (string) these values are known before the Scale class is created and should be unique. so what is the best approach. create a immutable class ScaleValueDefinition with value and definition as properties and use it in a list. use a dictionary. use another way i didn't think of... and how to implement it. for option 1. i can use params ScaleValueDefinition[] ValueDefinitions in the constructor, but how to do it for the other options? and as last at what amount of value's (properties) should i choose one option over the other?

    Read the article

  • How to get better at solving Dynamic programming problems

    - by newbie
    I recently came across this question: "You are given a boolean expression consisting of a string of the symbols 'true', 'false', 'and', 'or', and 'xor'. Count the number of ways to parenthesize the expression such that it will evaluate to true. For example, there is only 1 way to parenthesize 'true and false xor true' such that it evaluates to true." I knew it is a dynamic programming problem so i tried to come up with a solution on my own which is as follows. Suppose we have a expression as A.B.C.....D where '.' represents any of the operations and, or, xor and the capital letters represent true or false. Lets say the number of ways for this expression of size K to produce a true is N. when a new boolean value E is added to this expression there are 2 ways to parenthesize this new expression 1. ((A.B.C.....D).E) ie. with all possible parenthesizations of A.B.C.....D we add E at the end. 2. (A.B.C.(D.E)) ie. evaluate D.E first and then find the number of ways this expression of size K can produce true. suppose T[K] is the number of ways the expression with size K produces true then T[k]=val1+val2+val3 where val1,val2,val3 are calculated as follows. 1)when E is grouped with D. i)It does not change the value of D ii)it inverses the value of D in the first case val1=T[K]=N.( As this reduces to the initial A.B.C....D expression ). In the second case re-evaluate dp[K] with value of D reversed and that is val1. 2)when E is grouped with the whole expression. //val2 contains the number of 'true' E will produce with expressions which gave 'true' among all parenthesized instances of A.B.C.......D i) if true.E = true then val2 = N ii) if true.E = false then val2 = 0 //val3 contains the number of 'true' E will produce with expressions which gave 'false' among all parenthesized instances of A.B.C.......D iii) if false.E=true then val3=( 2^(K-2) - N ) = M ie. number of ways the expression with size K produces a false [ 2^(K-2) is the number of ways to parenthesize an expression of size K ]. iv) if false.E=false then val3 = 0 This is the basic idea i had in mind but when i checked for its solution http://people.csail.mit.edu/bdean/6.046/dp/dp_9.swf the approach there was completely different. Can someone tell me what am I doing wrong and how can i get better at solving DP so that I can come up with solutions like the one given above myself. Thanks in advance.

    Read the article

  • PHP class data implementation

    - by Bakanyaka
    I'm studying OOP PHP and have watched two tutorials that implement user login\registration system as an example. But implementation varies. Which way will be more correct one to work with data such as this? Load all data retrieved from database as array into a property called something like _data on class creation and further methods operate with this property Create separate properties for each field retrieved from database, on class creation load all data fields into respective properties and operate with that properties separately? Then let's say I want to create a method that returns a list of all users with their data. Which way is better? Method that returns just an array of userdata like this: Array([0]=>array([id] => 1, [username] => 'John', ...), [1]=>array([id] => 2, [username] => 'Jack', ...), ...) Method that creates a new instance of it's class for each user and returns an array of objects

    Read the article

  • Access static class variable of parent class in Python

    - by fuenfundachtzig
    I have someting like this class A: __a = 0 def __init__(self): A.__a = A.__a + 1 def a(self): return A.__a class B(A): def __init__(self): # how can I access / modify A.__a here? A.__a = A.__a + 1 # does not work def a(self): return A.__a Can I access the __astatic variable in B? It's possible writing a instead of __a, is this the only way? (I guess the answer might be rather short: yes :)

    Read the article

  • Rails 3 Abstract Class vs Inherited Class

    - by R. Yanchuleff
    In my rails 3 model, I have two classes: Product, Service. I want both to be of type InventoryItem because I have another model called Store and Store has_many :InventoryItems This is what I'm trying to get to, but I'm not sure how to model this in my InventoryItem model and my Product and Service models. Should InventoryItem just be a parent class that Product and Service inherit from, or should InventoryItem be modeled as a class abstract of which Product and Service extend from. Thanks in advance for the advice!

    Read the article

  • Setting attributes of a class during construction from **kwargs

    - by Carson Myers
    Python noob here, Currently I'm working with SQLAlchemy, and I have this: from __init__ import Base from sqlalchemy.schema import Column, ForeignKey from sqlalchemy.types import Integer, String from sqlalchemy.orm import relationship class User(Base): __tablename__ = "users" id = Column(Integer, primary_key=True) username = Column(String, unique=True) email = Column(String) password = Column(String) salt = Column(String) openids = relationship("OpenID", backref="users") User.__table__.create(checkfirst=True) #snip definition of OpenID class def create(**kwargs): user = User() if "username" in kwargs.keys(): user.username = kwargs['username'] if "email" in kwargs.keys(): user.username = kwargs['email'] if "password" in kwargs.keys(): user.password = kwargs['password'] return user This is in /db/users.py, so it would be used like: from db import users new_user = users.create(username="Carson", password="1234") new_user.email = "[email protected]" users.add(new_user) #this function obviously not defined yet but the code in create() is a little stupid, and I'm wondering if there's a better way to do it that doesn't require an if ladder, and that will fail if any keys are added that aren't in the User object already. Like: for attribute in kwargs.keys(): if attribute in User: user.__attribute__[attribute] = kwargs[attribute] else: raise Exception("blah") that way I could put this in its own function (unless one hopefully already exists?) So I wouldn't have to do the if ladder again and again, and so I could change the table structure without modifying this code. Any suggestions?

    Read the article

  • base class , inheritate class sizeof()

    - by user1279988
    why sizeof(X) is 4 and sizeof(Y) is 8? and another question, in class X, only the int(i) count as sizeof() 4? member function does take any memory space? Plz tell me, thanks! class X { int i; public: X() { i = 0; } void set(int ii) { i = ii; } int read() const { return i; } int permute() { return i = i * 47; } }; class Y : public X { int i; // Different from X's i public: Y() { i = 0; } int change() { i = permute(); // Different name call return i; } void set(int ii) { i = ii; X::set(ii); // Same-name function call } }; cout << "sizeof(X) = " << sizeof(X) << endl; cout << "sizeof(Y) = "

    Read the article

  • Is there a real difference between dynamic analysis and testing?

    - by user970696
    Often testing is regarded as a dynamic analysis of a software. Yet while writing my thesis, the reviewer noted to me that dynamic analysis is about analyzing the program behind the scenes - e.g. profiling and that it is not the same as testing because its "analysis" which looks inside and observes. I know that "static analysis" is not testing, should we then separate this "dynamic analysis" also from testing? Some books do refer to dynamic analysis in this sense. I would maybe say that testing is a one mean of dynamic analysis?

    Read the article

  • Compare base class part of sub class instance to another base class instance

    - by Anders Abel
    I have number of DTO classes in a system. They are organized in an inheritance hierarchy. class Person { public int Id { get; set; } public string FirstName { get; set; } public string ListName { get; set; } } class PersonDetailed : Person { public string WorkPhone { get; set; } public string HomePhone { get; set; } public byte[] Image { get; set; } } The reason for splitting it up is to be able to get a list of people for e.g. search results, without having to drag the heavy image and phone numbers along. Then the full PersonDetail DTO is loaded when the details for one person is selected. The problem I have run into is comparing these when writing unit tests. Assume I have Person p1 = myService.GetAPerson(); PersonDetailed p2 = myService.GetAPersonDetailed(); // How do I compare the base class part of p2 to p1? Assert.AreEqual(p1, p2); The Assert above will fail, as p1 and p2 are different classes. Is it possible to somehow only compare the base class part of p2 to p1? Should I implement IEquatable<> on Person? Other suggestions?

    Read the article

  • Ubuntu Screenshot Window Class

    - by Weylin Schreck
    I would like to know the class for the "thing" that pops up when you take a screen shot using the default screen capture utility in Ubuntu 12.04. When I do a full screen capture it lags a lot because of particular animation I use to open things like drop down menus. Therefore I’d like to disable that only. If someone could provide me with the window "class=" or however I would disable the animation there it would be greatly appreciated.

    Read the article

  • How do I set an array in one class with another array in another class

    - by Stef
    I've populated and array with data like this in one class... PowerClass.h NSMutableArray pickerArray; @property (nonatomic, retain) NSMutableArray pickerArray; - PowerClass.m @synthesize pickerArray; @implementation NSMutableArray *array = [[NSArray alloc] initWithObjects:@"stef", @"steve", @"baddamans", @"jonny", nil]; pickerArray = [NSMutableArray arrayWithArray:array]; And I'm trying to set the Array in another class WeekClass.h PowerClass *powerClass; NSMutableArray *pickerData; @property (nonatomic, retain) NSMutableArray pickerData; @property (nonatomic, retain) PowerClass *powerClass; WeekClass.m @implementation pickerData = [NSMutableArray arrayWithArray:powerClass.pickerArray]; I have no errors or warnings. It just crashes. The NSLog says that the powerClass.pickerArray is NULL. Please help point me in the right direction.

    Read the article

  • Global qualification in a class declarations class-head

    - by gf
    We found something similar to the following (don't ask ...): namespace N { struct A { struct B; }; } struct A { struct B; }; using namespace N; struct ::A::B {}; // <- point of interest Interestingly, this compiles fine with VS2005, icc 11.1 and Comeau (online), but fails with GCC: global qualification of class name is invalid before '{' token From C++03, Annex A, it seems to me like GCC is right: the class-head can consist of nested-name-specifier and identifier nested-name-specifier can't begin with a global qualification (::) obviously, neither can identifier ... or am i overlooking something?

    Read the article

  • Sending object C from class A to class B

    - by user278618
    Hi, I can't figure out how to design classes in my system. In classA I create object selenium (it simulates user actions at website). In this ClassA I create another objects like SearchScreen, Payment_Screen and Summary_Screen. # -*- coding: utf-8 -*- from selenium import selenium import unittest, time, re class OurSiteTestCases(unittest.TestCase): def setUp(self): self.verificationErrors = [] self.selenium = selenium("localhost", 5555, "*chrome", "http://www.someaddress.com/") time.sleep(5) self.selenium.start() def test_buy_coffee(self): sel = self.selenium sel.open('/') sel.window_maximize() search_screen=SearchScreen(self.selenium) search_screen.choose('lavazza') payment_screen=PaymentScreen(self.selenium) payment_screen.fill_test_data() summary_screen=SummaryScreen(selenium) summary_screen.accept() def tearDown(self): self.selenium.stop() self.assertEqual([], self.verificationErrors) if __name__ == "__main__": unittest.main() It's example SearchScreen module: class SearchScreen: def __init__(self,selenium): self.selenium=selenium def search(self): self.selenium.click('css=button.search') I want to know if there is anything ok with a design of those classes?

    Read the article

  • Class library modification / migration

    - by Clint
    I have 3 class libraries. A BBL, a DAL, and a DATA (about 15 datasets). Currently 4 [major] applications utilize the functionality in these DLL's. I'm rewriting one of those applications and I need to (1) Use some of the existing functionality in the libraries (2) Change some of it (3) Add new functionality (4) Add new datasets. I'm back and forth about the best way to do this, while keeping my risks at a minimum. Some thoughts.. 1) Use the existing projects and don't make any modifications, only additions 2) Make new libraries, bring over the code I can use, and make additions as needed 3) Implement partial classes in the existing projects Eventually all 4 applications will use the newest functionality, but it will be a slow migration; so the old code can't be depricated yet. Any thoughts?

    Read the article

  • designing solution to dynamically load class

    - by dot
    Background Information I have a web app that allows end users to connect to ssh-enabled devices and manipulate them. Right now, i only support one version of firmware. The logic is something like this: user clicks on a button to run some command on device. web application looks up the class name containing the correct ssh interface for the device, using the device's model name. (because the number of hardware models is so small, i have a list that's hardcoded in my web app) web app creates a new ssh object using the class loaded in step 2. ssh command is run and session closed. command results displayed on web page. This all works fine. Now the end user wants me to be able to support multiple versions of firmware. But the catch is, they don't want to have to document the firmware version anywhere becuase the amount of overhead this will create in maintaining the system database. In other words, I can't look up the firmware version based on the device. The good news is that it sounds like at most, I'll have to support two different versions of firmware per device. One option is to name the the classes like this: deviceX.1.php deviceX.2.php deviceY.1.php deviceY.2.php where "X" and "Y" represent the model names, and 1 and 2 represent the firmware versions. When a user runs a command, I will first try it with one of the class files, if it fails, i can try with the second. I think always try the newer version of firmware first... so let's say in the above example, I would load deviceX.2.php before deviceX.1.php. This will work, but it's not very efficient. But I can't think of another way around this. Any suggestions?

    Read the article

  • How to find rows between other rows w/ID then add class

    - by Ravex
    Hi guys. i'm stuck with my table. need create toggle rows function. but i no idea how to find sub rows in table. Some one can help me? I have table with many rows 500 All Rows have class="row-1,row-2.....row-600 etc" And all main rows also have class="parent" between each "parent" rows i have 6 rows So i need for toggle/collapse purposes find all (sub)rows betwen parent rows. and add class with id like in prevous parent row. For example: parent have class="row-1 parent" all sub must have - class="child-row-1" default table <table id="table"> <tr class="row-1 odd parent"> <th class="column-1">st. 3 - 5</th> <th class="column-2">Profile</th> <th class="column-3">Purpose</th> </tr> <tr class="row-2 even"> <td class="column-1">Metal Stamp</td> <td class="column-2">Width</td> <td class="column-3">Price</td> </tr> <tr class="row-3 odd"> <td class="column-1">Circle 3 - 5</td> <td class="column-2">28-110</td> <td class="column-3">21500</td> </tr> <tr class="row-4 even"> <td class="column-1">Circle 3 - 5</td> <td class="column-2">115-180</td> <td class="column-3">20700</td> </tr> <tr class="row-5 odd"> <td class="column-1">Cube 3 - 5</td> <td class="column-2">63-80</td> <td class="column-3">21500</td> </tr> <tr class="row-6 even"> <td class="column-1">Cube 3 - 5</td> <td class="column-2">100-220</td> <td class="column-3">20700</td> </tr> <tr class="row-7 odd"> <td class="column-1">Line 3 - 5</td> <td class="column-2">10-50 ? 40-200</td> <td class="column-3">27000</td> </tr> </table> in the end it should look like this: <table id="table"> <tr class="row-1 odd parent"> <th class="column-1">st. 3 - 5</th> <th class="column-2">Profile</th> <th class="column-3">Purpose</th> </tr> <tr class="row-2 even child-row-1"> <td class="column-1">Metal Stamp</td> <td class="column-2">Width</td> <td class="column-3">Price</td> </tr> <tr class="row-3 odd child-row-1"> <td class="column-1">Circle 3 - 5</td> <td class="column-2">28-110</td> <td class="column-3">21500</td> </tr> <tr class="row-4 even child-row-1"> <td class="column-1">Circle 3 - 5</td> <td class="column-2">115-180</td> <td class="column-3">20700</td> </tr> <tr class="row-5 odd child-row-1"> <td class="column-1">Cube 3 - 5</td> <td class="column-2">63-80</td> <td class="column-3">21500</td> </tr> <tr class="row-6 even child-row-1"> <td class="column-1">Cube 3 - 5</td> <td class="column-2">100-220</td> <td class="column-3">20700</td> </tr> <tr class="row-7 odd child-row-1"> <td class="column-1">Line 3 - 5</td> <td class="column-2">10-50 ? 40-200</td> <td class="column-3">27000</td> </tr> </table>

    Read the article

  • Is it appropriate for a class to only be a collection of information with no logic?

    - by qegal
    Say I have a class Person that has instance variables age, weight, and height, and another class Fruit that has instance variables sugarContent and texture. The Person class has no methods save setters and getters, while the Fruit class has both setters and getters and logic methods like calculateSweetness. Is the Fruit class the type of class that is better practice than the Person class. What I mean by this is that the Person class seems like it doesn't have much purpose; it exists solely to organize data, while the Fruit class organizes data and actually contains methods for logic.

    Read the article

  • Verification of UML Class Diagram

    - by Jean Carlos Suárez Marranzini
    This is my UML Class Diagram made in Astah Community, for a tennis scoreboard game. Here's a link to the image (I don't have enough rep to post images): http://i47.tinypic.com/2lsxx90.png Points are calculated based on moves. Moves can be either points (for the player's advantage) or errors (for the opponent's advantage). The Time Machine allows you to travel to previous game states (expressed as scoreboards). The storage component should be able to store matches independently of the serialization format. The serializers and deserializers should be able to do their job regardless of where the storage lies. The GameEngine should be able to apply the rules of the game regardless of the particularities of the game (hence, dependency injection through the Settings class). The outcomes of games, sets and matches should be deducible based on the points and the rules to apply (the logic implementations are there to provide the rules). Could you please verify my design and tell me if there's anything wrong with it? Thanks in advance.

    Read the article

  • Stopping duplicate H1 and title from dynamic content

    - by codemonkey
    I have a web site where there are lots of dynamically (database driven) created pages. These pages are basically used to show uploaded images The pages look a bit like this URL: http://www.mywebsite.com/page-id/page-title/ H1: View from the sea This is a big issue because I might have 10 other pages with the title: 'View from the sea'. I know the simple solution would be to make sure the pages are named differently but I have lots of users on the web site so it's not that simple. What do you guys think to putting the page-id with the page-title in the H1 tag? So it might read 437 - View from the sea. I need to differentiate the h1 titles. I think using the page-id would help but if anyone has a better solution that would be great! Thanks in advance

    Read the article

  • adding tagged / dynamic pages in sitemap

    - by sam
    ive got a blog thats been running for about a year ive made about 200 posts, and there should be about 220 pages to index (additional pages for about / contact ect). When i go to crawl the site i get 1900 pages because of all the pages that are related to tags ive used in my blogs these 70% of these pages only contain one blog post. When submitting my site map to google should i exclude all pages with /tagged/ in the url so ill only be submitting unqiue pages, or should i submit the full site map ?

    Read the article

  • Is it good or bad to have dynamic content in page titles and/or description

    - by Gunjan
    In a local listing website, I append number of search results found in the description(not in title currntly) meta tag of the page as I think this is valuable for users for e.g. "Find address, phone numbers, blah blah blah for 21 outlets in locality. some more stuff after this..." as more places are added to the database, the description for the same page will change frequently. is this good or bad for SEO how about doing the same for title tags?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >