Search Results

Search found 9771 results on 391 pages for 'equivalence classes'.

Page 195/391 | < Previous Page | 191 192 193 194 195 196 197 198 199 200 201 202  | Next Page >

  • C# Different class objects in one list

    - by jeah_wicer
    I have looked around some now to find a solution to this problem. I found several ways that could solve it but to be honest I didn't realize which of the ways that would be considered the "right" C# or OOP way of solving it. My goal is not only to solve the problems but also to develop a good set of code standards and I'm fairly sure there's a standard way to handle this problem. Let's say I have 2 types of printer hardwares with their respective classes and ways of communicating: PrinterType1, PrinterType2. I would also like to be able to later on add another type if neccessary. One step up in abstraction those have much in common. It should be possible to send a string to each one of them as an example. They both have variables in common and variables unique to each class. (One for instance communicates via COM-port and has such an object, while the other one communicates via TCP and has such an object). I would however like to just implement a List of all those printers and be able to go through the list and perform things as "Send(string message)" on all Printers regardless of type. I would also like to access variables like "PrinterList[0].Name" that are the same for both objects, however I would also at some places like to access data that is specific to the object itself (For instance in the settings window of the application where the COM-port name is set for one object and the IP/port number for another). So, in short something like: In common: Name Send() Specific to PrinterType1: Port Specific to PrinterType2: IP And I wish to, for instance, do Send() on all objects regardless of type and the number of objects present. I've read about polymorphism, Generics, interfaces and such, but I would like to know how this, in my eyes basic, problem typically would be dealt with in C# (and/or OOP in general). I actually did try to make a base class, but it didn't quite seem right to me. For instance I have no use of a "string Send(string Message)" function in the base class itself. So why would I define one there that needs to be overridden in the derived classes when I would never use the function in the base class ever in the first place? I'm really thankful for any answers. People around here seem very knowledgeable and this place has provided me with many solutions earlier. Now I finally have an account to answer and vote with too. EDIT: To additionally explain, I would also like to be able to access the objects of the actual printertype. For instance the Port variable in PrinterType1 which is a SerialPort object. I would like to access it like: PrinterList[0].Port.Open() and have access to the full range of functionality of the underlaying port. At the same time I would like to call generic functions that work in the same way for the different objects (but with different implementations): foreach (printer in Printers) printer.Send(message)

    Read the article

  • Creating and Compiling a C++ project on Windows

    - by sc_ray
    I need to work on C++ project on my windows machine. My project will consist of various classes(.h and .cpp) as well as the startup file to start the application. The preliminary design is simple but the application has the potential to gain complexity as time goes by. What I need here is ideas to set up the C++ project compiler/IDE/Makefile etc..etc. as well as some standard tools besides Visual C++ to compile/build/link projects such as these on a Windows OS. Thanks

    Read the article

  • importing class and its function from another file [Python]

    - by user343934
    Hi everyone, I am having little bit problem in importing classes in python. My work flow goes like this -index.py ---class template: ------def header(): ------def body(): ------def footer(): -display.py I want to call function header(), body() and footer () in my display.py page. Will anyone make me clear about this issue in python. Thanks for your concern.

    Read the article

  • How do i escape reserve names in a column? MySQL/Create Table

    - by acidzombie24
    I am generating tables from classes in .NET and one problem is a class may have a field name key which is a reserved mysql keyword. How do i escape it in a create table statement? (Note: The other problem below is text must be a fixed size to be indexed/unique) create table if not exists misc_info ( id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL, key TEXT UNIQUE NOT NULL, value TEXT NOT NULL)ENGINE=INNODB;

    Read the article

  • How to validate user with SimpleMembership

    - by Rushino
    I am using SimpleMembership for user login stuff in my web application. I wrote a console that actually access my web application classes to avoid duplicate code. However, since my console application doesn't have anything related to user sessions the Login method doesn't work. But is there a way to validate a user only using the SimpleMembership? In case i have to do it manually.. how can i do it ?

    Read the article

  • C++ Template Usage

    - by MalcomTucker
    If I have a template definition like the one below, can someone provide a code sample for how I would actually instantiate an instance of this with two of my own classes? template <class T1, class T2> class LookUpTable { public: LookUpTable(); void set(Tl x, T2* y); T2* get(Tl x); }; Thanks.

    Read the article

  • Is it the best practice to extract an interface for every class?

    - by the_drow
    I have seen code where every class has an interface that it implements. Sometimes there is no common interface for them all. They are just there and they are used instead of concreate objects. They do not offer a generic interface for two classes and are specific to the domain of the problem that the class solves. Is there any reason to do that?

    Read the article

  • Initiatives to namespace PHP core and libraries

    - by James Maroney
    With the introduction of Object-Oriented and Namespacing capabilities in PHP, I am loving the new found cleanliness of PHP code that can be produced. The annoying thing though is that the core of PHP is still cluttered, unorganized mess of functions. Are there any initiatives to organize the PHP core and "common" libraries into namespaces and classes?

    Read the article

  • if i call an interface method will it get the method body from implementation class and execute ?

    - by sij
    please forgive me if i am wrong: I have an interface Interface1 I have its implementation Imple implements Interface (all methods hav been implemented :) ) now consider a third class CheckCall can I do a call in the class CheckCall like I mention below Interface1 interface1; interface1.method(); all necessary imports have been done. Please tell me is it possible or not , if not then ok and if yes then tell me what will happen if i have more than one impl classes for the same interface and i am doing the same call.

    Read the article

  • how to have minimum AreaRegistrations with putting duplicated elements in single place

    - by Sadegh
    hi all, i have several AreaRegistration classes which one each registers own routes and each one have some duplicated elements such as bolded text in below: context.MapRoute("Search", "**{culture}/{style}**/search", new { **culture = cultureValue, style = styleValue,** controller = "search", action = "default" }, new { **culture = new CultureRouteConstraint(), style = new StyleRouteConstraint()** }); how i can have minimum AreaRegistrations with putting duplicated elements in single place which handles that? this is possible?

    Read the article

  • Determining the calling package

    - by Nachikethas
    I got a package called 1.pm in that the constructor is calling a subroutine which is in the same package. Now if some other classes say 2.pm is calling the constructor defined in 1.pm how can i determine if the subroutine is called from 2.pm ?

    Read the article

  • Consuming REST based web services in .Net

    - by steve
    Greetings, I'm confused as to the best approach to make when consuming REST based web services with .Net. At the moment I'm using the System.net.webclient class. Should I be using Webresponse, webrequest classes in System.Net ? If I were to use another approach (Other than webclient) what disadvantages / advantages would I gain ? Thanks,

    Read the article

  • Python/Django tests running only one test at a time

    - by user2876296
    I have a unittest for my view class TestFromAllAdd(TestCase): fixtures = ['staging_accounts_user.json', 'staging_main_category.json', 'staging_main_dashboard.json', 'staging_main_location.json', 'staging_main_product.json', 'staging_main_shoppinglist.json'] def setUp(self): self.factory = RequestFactory() self.c = Client() self.c.login(username='admin', password='admin') def from_all_products_html404_test(self): request = self.factory.post('main/adding_from_all_products', {'product_id': ''}) request.user = User.objects.get(username= 'admin') response = adding_from_all_products(request) self.assertEqual(response.status_code, 404) But I have a few more classes with tests and I cant run them all at the same time: python manage.py test main doesnt run tests, but if i run; python manage.py test main.TestFromAllAdd.from_all_products_html404_test , runs one test;

    Read the article

  • purpose of php consutructor

    - by Bharanikumar
    Hi , Am working in the classes and object class structure , but not extream level , Just class and function , then in one place instantiation . that's it , not much big functions like __construct etc , Please tell me very simply , 1.what is th purpose of constructor ad destructor , But i know theoretical explanation school level , But i am expecting something like in real time , which situation we have to use, and is there any example for that please tell me, Regards

    Read the article

  • Business object and linq2SQL

    - by Overdose
    What is the optimal way to write the code which interacts with DB using linq2SQL? I need to add some business logic to the entities. So I guess there are two ways: Write some wrapper class. The main minus is that many fields are the same, so i don't feel it as DRY style. Add business logic methods to linq2sql entities(these classes are partial) directly ???

    Read the article

  • One log4j.xml - many scripts

    - by psed
    One of my utility jar files is used by different nix scripts, located in different categories. Problem: unable to initialize log4j framework (unable to find log4j.xml). Solution, that allows to configure logger correctly while launching jar classes by different scripts - usage of env vars and force configuring using DOMConfigurtor.configure(pathToConfXml) method. is it possible to avoid path hardcoding and configure logger inside of a script? Appreciate all your help. Thanks.

    Read the article

  • Alternatives to persisting objects than using __destruct() in PHP

    - by Michael
    I usually use a classes destructor method __destruct() to persist objects to session or what have you. It is just very convinient, but I'm curious to if there are any other methods that are equally appealing. Do you know of such? The curiousity arose as I was to merge/utilize two frameworks that both made use of __destruct() for persistance resulting in a race-problem.

    Read the article

  • Static member class - declare class private and class member package-private?

    - by Helper Method
    Consider you have the following class public class OuterClass { ... private static class InnerClass { int foo; int bar; } } I think I've read somewhere (but not the official Java Tutorial) that if I would declare the static member classes attributes private, the compiler had to generate some sort of accessor methods so that the outer class can actually access the static member class's (which is effectively a package-private top level class) attributes. Any ideas on that?

    Read the article

< Previous Page | 191 192 193 194 195 196 197 198 199 200 201 202  | Next Page >