Search Results

Search found 8634 results on 346 pages for 'base'.

Page 22/346 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • 'abstract class' versus 'normal class' for a reusable library

    - by Greg
    I'm developing a reusable library and have been creating abstract classes, so the client can then extend from these. QUESTION: Is there any reason in fact I should use an abstract class here as opposed to just a normal class? Note - Have already decided I do not want to use interfaces as I want to include actual default methods in my library so the client using it doesn't have to write the code.

    Read the article

  • Does this MSDN article violate MVVM?

    - by rasx
    This may be old news but back in March 2009, this article, “Model-View-ViewModel In Silverlight 2 Apps,” has a code sample that includes DataServiceEntityBase: // COPIED FROM SILVERLIGHTCONTRIB Project for simplicity /// <summary> /// Base class for DataService Data Contract classes to implement /// base functionality that is needed like INotifyPropertyChanged. /// Add the base class in the partial class to add the implementation. /// </summary> public abstract class DataServiceEntityBase : INotifyPropertyChanged { /// <summary> /// The handler for the registrants of the interface's event /// </summary> PropertyChangedEventHandler _propertyChangedHandler; /// <summary> /// Allow inheritors to fire the event more simply. /// </summary> /// <param name="propertyName"></param> protected void FirePropertyChanged(string propertyName) { if (_propertyChangedHandler != null) { _propertyChangedHandler(this, new PropertyChangedEventArgs(propertyName)); } } #region INotifyPropertyChanged Members /// <summary> /// The interface used to notify changes on the entity. /// </summary> event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { _propertyChangedHandler += value; } remove { _propertyChangedHandler -= value; } } #endregion What this class implies is that the developer intends to bind visuals directly to data (yes, a ViewModel is used but it defines an ObservableCollection of data objects). Is this design diverging too far from the guidance of MVVM? Now I can see some of the reasons Why would we go this way: what we can do with DataServiceEntityBase is this sort of thing (which is intimate with the Entity Framework): // Partial Method to support the INotifyPropertyChanged interface public partial class Game : DataServiceEntityBase { #region Partial Method INotifyPropertyChanged Implementation // Override the Changed partial methods to implement the // INotifyPropertyChanged interface // This helps with the Model implementation to be a mostly // DataBound implementation partial void OnDeveloperChanged() { base.FirePropertyChanged("Developer"); } partial void OnGenreChanged() { base.FirePropertyChanged("Genre"); } partial void OnListPriceChanged() { base.FirePropertyChanged("ListPrice"); } partial void OnListPriceCurrencyChanged() { base.FirePropertyChanged("ListPriceCurrency"); } partial void OnPlayerInfoChanged() { base.FirePropertyChanged("PlayerInfo"); } partial void OnProductDescriptionChanged() { base.FirePropertyChanged("ProductDescription"); } partial void OnProductIDChanged() { base.FirePropertyChanged("ProductID"); } partial void OnProductImageUrlChanged() { base.FirePropertyChanged("ProductImageUrl"); } partial void OnProductNameChanged() { base.FirePropertyChanged("ProductName"); } partial void OnProductTypeIDChanged() { base.FirePropertyChanged("ProductTypeID"); } partial void OnPublisherChanged() { base.FirePropertyChanged("Publisher"); } partial void OnRatingChanged() { base.FirePropertyChanged("Rating"); } partial void OnRatingUrlChanged() { base.FirePropertyChanged("RatingUrl"); } partial void OnReleaseDateChanged() { base.FirePropertyChanged("ReleaseDate"); } partial void OnSystemNameChanged() { base.FirePropertyChanged("SystemName"); } #endregion } Of course MSDN code can seen as “toy code” for educational purposes but is anyone doing anything like this in the real world of Silverlight development?

    Read the article

  • Why do the overloads of String.Format exist?

    - by GiddyUpHorsey
    I was using Reflector to look at the implementation of String.Format and had always been under the impression that the overloads of String.Format that took 1, 2 & 3 arguments were optimized versions of the method that takes an object array. However, what I found was that internally they create an object array and then call a method that takes an object array. 1 arg public static string Format(string format, object arg0) { if (format == null) { throw new ArgumentNullException("format"); } return Format(null, format, new object[] { arg0 }); } 2 args public static string Format(string format, object arg0, object arg1) { if (format == null) { throw new ArgumentNullException("format"); } return Format(null, format, new object[] { arg0, arg1 }); } 3 args public static string Format(string format, object arg0, object arg1, object arg2) { if (format == null) { throw new ArgumentNullException("format"); } return Format(null, format, new object[] { arg0, arg1, arg2 }); } Object array public static string Format(string format, params object[] args) { if ((format == null) || (args == null)) { throw new ArgumentNullException((format == null) ? "format" : "args"); } return Format(null, format, args); } Internally they all end up using the same code and so using the 1, 2 & 3 argument versions are no faster than the object array version. So my question is - why do they exist? When you use the object array version with a comma separated list of values, the compiler automatically converts the arguments into an object array because of the params/ParamArray keyword which is essentially what the 1, 2 & 3 versions do, so they seem redundant. Why did the BCL designers add these overloads?

    Read the article

  • Ways to gain a deeper understanding of programming concepts?

    - by MrPlow
    I'm a marketer and have been messing around in PHP/MySQL for years. Recently (the last several months) I've been making my own scripts/programs in Python and I've really enjoyed the whole problem solving process. I've read(skimmed) some books and understand the basics of OOP, polymorphism, etc.. I have a general interest in AI and Natural Language in particular but it seems these things require a masters in Computer Science. My knowledge of math is poor. The last class I took was calculus, and I've forgotten the majority of it. Basically I'm looking for things to learn that will help me think in a more analytic way, and maybe see solutions where I didn't before. Improving my ability to program in Python would be nice too. I don't need to learn a specific language or something for employment, just enjoyment. Although my work often involves web development so some utility would be nice. I don't like learning concepts by just reading them. I need to apply them, even if the examples are contrived. A recommendation of a couple good books or other resources would be nice. :) Apologies if this is too vague/misplaced...

    Read the article

  • With this generics code why am I getting "Argument 1: cannot convert from 'ToplogyLibrary.Relationsh

    - by Greg
    Hi, Any see why I'm getting a "Argument 1: cannot convert from 'ToplogyLibrary.RelationshipBase' to 'TRelationship'" in the code below, in CreateRelationship() ? public class TopologyBase<TKey, TNode, TRelationship> where TNode : NodeBase<TKey>, new() where TRelationship : RelationshipBase<TKey>, new() { // Properties public Dictionary<TKey, TNode> Nodes { get; private set; } public List<TRelationship> Relationships { get; private set; } // Constructors protected TopologyBase() { Nodes = new Dictionary<TKey, TNode>(); Relationships = new List<TRelationship>(); } // Methods public TNode CreateNode(TKey key) { var node = new TNode {Key = key}; Nodes.Add(node.Key, node); return node; } public void CreateRelationship(TNode parent, TNode child) { // Validation if (!Nodes.ContainsKey(parent.Key) || !Nodes.ContainsKey(child.Key)) { throw new ApplicationException("Can not create relationship as either parent or child was not in the graph: Parent:" + parent.Key + ", Child:" + child.Key); } // Add Relationship var r = new RelationshipBase<TNode>(); r.Parent = parent; r.Child = child; Relationships.Add(r); // *** HERE *** "Argument 1: cannot convert from 'ToplogyLibrary.RelationshipBase<TNode>' to 'TRelationship'" } } public class RelationshipBase<TNode> { public TNode Parent { get; set; } public TNode Child { get; set; } } public class NodeBase<T> { public T Key { get; set; } public NodeBase() { } public NodeBase(T key) { Key = key; } }

    Read the article

  • How do i write tasks? (parallel code)

    - by acidzombie24
    I am impressed with intel thread building blocks. I like how i should write task and not thread code and i like how it works under the hood with my limited understanding (task are in a pool, there wont be 100 threads on 4cores, a task is not guaranteed to run because it isnt on its own thread and may be far into the pool. But it may be run with another related task so you cant do bad things like typical thread unsafe code). I wanted to know more about writing task. I like the 'Task-based Multithreading - How to Program for 100 cores' video here http://www.gdcvault.com/sponsor.php?sponsor_id=1 (currently second last link. WARNING it isnt 'great'). My fav part was 'solving the maze is better done in parallel' which is around the 48min mark (you can click the link on the left side. That part is really all you need to watch if any). However i like to see more code examples and some API of how to write task. Does anyone have a good resource? I have no idea how a class or pieces of code may look after pushing it onto a pool or how weird code may look when you need to make a copy of everything and how much of everything is pushed onto a pool.

    Read the article

  • Few Basic Questions in Overriding

    - by Dahlia
    I have few problems with my basic and would be thankful if someone can clear this. What does it mean when I say base *b = new derived; Why would one go for this? We very well separately can create objects for class base and class derived and then call the functions accordingly. I know that this base *b = new derived; is called as Object Slicing but why and when would one go for this? I know why it is not advisable to convert the base class object to derived class object (because base class is not aware of the derived class members and methods). I even read in other StackOverflow threads that if this is gonna be the case then we have to change/re-visit our design. I understand all that, however, I am just curious, Is there any way to do this? class base { public: void f(){cout << "In Base";} }; class derived:public base { public: void f(){cout << "In Derived";} }; int _tmain(int argc, _TCHAR* argv[]) { base b1, b2; derived d1, d2; b2 = d1; d2 = reinterpret_cast<derived*>(b1); //gives error C2440 b1.f(); // Prints In Base d1.f(); // Prints In Derived b2.f(); // Prints In Base d1.base::f(); //Prints In Base d2.f(); getch(); return 0; } In case of my above example, is there any way I could call the base class f() using derived class object? I used d1.base()::f() I just want to know if there any way without using scope resolution operator? Thanks a lot for your time in helping me out!

    Read the article

  • How do i write task? (parallel code)

    - by acidzombie24
    I am impressed with intel thread building blocks. I like how i should write task and not thread code and i like how it works under the hood with my limited understanding (task are in a pool, there wont be 100 threads on 4cores, a task is not guaranteed to run because it isnt on its own thread and may be far into the pool. But it may be run with another related task so you cant do bad things like typical thread unsafe code). I wanted to know more about writing task. I like the 'Task-based Multithreading - How to Program for 100 cores' video here http://www.gdcvault.com/sponsor.php?sponsor_id=1 (currently second last link. WARNING it isnt 'great'). My fav part was 'solving the maze is better done in parallel' which is around the 48min mark (you can click the link on the left side). However i like to see more code examples and some API of how to write task. Does anyone have a good resource? I have no idea how a class or pieces of code may look after pushing it onto a pool or how weird code may look when you need to make a copy of everything and how much of everything is pushed onto a pool.

    Read the article

  • Updating only .dll of a reference in my ASP.NET Application

    - by Mike C.
    Hello, I have a deployed web application project that references my Utility.dll class library. I want to make a change to the Utlity.dll and roll only that .dll out. The problem is that when I do that, I get the following error when I try to launch my site: Could not load file or assembly 'Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3766481cef20a9d1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Is there a setting I can change so I don't have to roll out the entire web application project - only the Utlity.dll? Thanks!

    Read the article

  • How to "wrap" implementation in C#

    - by igor
    Hello, I have these classes in C# (.NET Framework 3.5) described below: public class Base { public int State {get; set;} public virtual int Method1(){} public virtual string Method2(){} ... public virtual void Method10(){} } public class B: Base { // some implementation } public class Proxy: Base { private B _b; public class Proxy(B b) { _b = b; } public override int Method1() { if (State == Running) return _b.Method1(); else return base.Method1(); } public override string Method2() { if (State == Running) return _b.Method2(); else return base.Method2(); } public override void Method10() { if (State == Running) _b.Method10(); else base.Method10(); } } I want to get something this: public Base GetStateDependentImplementation() { if (State == Running) // may be some other rule return _b; else return base; // compile error } and my Proxy's implementation will be: public class Proxy: Base { ... public override int Method1() { return GetStateDependentImplementation().Method1(); } public override string Method2() { return GetStateDependentImplementation().Method2(); } ... } Of course, I can do this (aggregation of base implementation): public RepeaterOfBase: Base // no any overrides, just inheritance { } public class Proxy: Base { private B _b; private RepeaterOfBase _Base; public class Proxy(B b, RepeaterOfBase aBase) { _b = b; _base = aBase; } } ... public Base GetStateDependentImplementation() { if (State == Running) return _b; else return _Base; } ... But instance of Base class is very huge and I have to avoid to have other additional copy in memory. So I have to simplify my code have to "wrap" implementation have to avoid a code duplication have to avoid aggregation of any additional instance of Base class (duplication) Is it possible to reach these goals?

    Read the article

  • Fastest way to find the largest power of 10 smaller than x

    - by peoro
    Is there any fast way to find the largest power of 10 smaller than a given number? I'm using this algorithm, at the moment, but something inside myself dies anytime I see it: 10**( int( math.log10(x) ) ) # python pow( 10, (int) log10(x) ) // C I could implement simple log10 and pow functions for my problems with one loop each, but still I'm wondering if there is some bit magic for decimal numbers.

    Read the article

  • Magento - How to manage multiple base currencies and multiple payment gateways?

    - by Diego
    I have two requirements to satisfy, I hope someone with more experience can help me sorting them out. Multiple Base Currencies My client wants to allow visitors to place orders in whatever currency they prefer, choosing from the ones he’ll configure. Magento only supports one Base Currency, and this is, obviously, not what I need. I checked the solution involving multiple websites, but I need a customer to be registered once and stay on the same website, not to switch from one to the other and have to register/log in on each. Manage multiple Payment Gateways per currency and per payment method This is another crucial requirement, and it’s tied to the first one. My client wants to “route” payments in different currencies to different accounts. He’ll thus have one for Euro, one for USD and one for GBP. Whenever a customer pays with one of these currencies, the payment gateway has to be chosen accordingly. Additionally, the gateway should be different depending on other rules. For example, if customer pays with a Debit Card, my client will have a payment gateway configured especially for it. If customer pays with MasterCard, the gateway will be different, and so on. The complication, in this case, arises from the fact that my client uses Realex Payments and, although it would be possible for him to open multiple accounts, the Realex module expects one single gateway. In a normal scenario, we would need up to six instead: Payment with Debit Card in Euro Payment with Credit Card in Euro Payment with Debit Card in US Dollars Payment with Credit Card in US Dollars Payment with Debit Card in GB Pounds Payment with Credit Card in GB Pounds This, of course, if he doesn’t decide to accept other payment methods, such as bank transfer, which would add one more gateway per currency. Is there a way to achieve the above in Magento? I never had such complicated requirements before, and I’m a bit lost. Thanks in advance for the help.

    Read the article

  • What is a good way to refactor a large, terribly written code base by myself? [closed]

    - by AgentKC
    Possible Duplicate: Techniques to re-factor garbage and maintain sanity? I have a fairly large PHP code base that I have been writing for the past 3 years. The problem is, I wrote this code when I was a terrible programmer and now it's tens of thousands of lines of conditionals and random MySQL queries everywhere. As you can imagine, there are a ton of bugs and they are extremely hard to find and fix. So I would like a good method to refactor this code so that it is much more manageable. The source code is quite bad; I did not even use classes or functions when I originally wrote it. At this point, I am considering rewriting the whole thing. I am the only developer and my time is pretty limited. I would like to get this done as quickly as possible, so I can get back to writing new features. Since rewriting the code would take a long time, I am looking for some methods that I can use to clean up the code as quickly as possible without leaving more bad architecture that will come back to haunt me later. So this is the basic question: What is a good way for a single developer to take a fairly large code base that has no architecture and refactor it into something with reasonable architecture that is not a nightmare to maintain and expand?

    Read the article

  • Implicit constructor available for all types derived from Base excepted the current type?

    - by Vincent
    The following code sum up my problem : template<class Parameter> class Base {}; template<class Parameter1, class Parameter2, class Parameter> class Derived1 : public Base<Parameter> { }; template<class Parameter1, class Parameter2, class Parameter> class Derived2 : public Base<Parameter> { public : // Copy constructor Derived2(const Derived2& x); // An EXPLICIT constructor that does a special conversion for a Derived2 // with other template parameters template<class OtherParameter1, class OtherParameter2, class OtherParameter> explicit Derived2( const Derived2<OtherParameter1, OtherParameter2, OtherParameter>& x ); // Now the problem : I want an IMPLICIT constructor that will work for every // type derived from Base EXCEPT // Derived2<OtherParameter1, OtherParameter2, OtherParameter> template<class Type, class = typename std::enable_if</* SOMETHING */>::type> Derived2(const Type& x); }; How to restrict an implicit constructor to all classes derived from the parent class excepted the current class whatever its template parameters, considering that I already have an explicit constructor as in the example code ? EDIT : For the implicit constructor from Base, I can obviously write : template<class OtherParameter> Derived2(const Base<OtherParameter>& x); But in that case, do I have the guaranty that the compiler will not use this constructor as an implicit constructor for Derived2<OtherParameter1, OtherParameter2, OtherParameter> ? EDIT2: Here I have a test : (LWS here : http://liveworkspace.org/code/cd423fb44fb4c97bc3b843732d837abc) #include <iostream> template<typename Type> class Base {}; template<typename Type> class Other : public Base<Type> {}; template<typename Type> class Derived : public Base<Type> { public: Derived() {std::cout<<"empty"<<std::endl;} Derived(const Derived<Type>& x) {std::cout<<"copy"<<std::endl;} template<typename OtherType> explicit Derived(const Derived<OtherType>& x) {std::cout<<"explicit"<<std::endl;} template<typename OtherType> Derived(const Base<OtherType>& x) {std::cout<<"implicit"<<std::endl;} }; int main() { Other<int> other0; Other<double> other1; std::cout<<"1 = "; Derived<int> dint1; // <- empty std::cout<<"2 = "; Derived<int> dint2; // <- empty std::cout<<"3 = "; Derived<double> ddouble; // <- empty std::cout<<"4 = "; Derived<double> ddouble1(ddouble); // <- copy std::cout<<"5 = "; Derived<double> ddouble2(dint1); // <- explicit std::cout<<"6 = "; ddouble = other0; // <- implicit std::cout<<"7 = "; ddouble = other1; // <- implicit std::cout<<"8 = "; ddouble = ddouble2; // <- nothing (normal : default assignment) std::cout<<"\n9 = "; ddouble = Derived<double>(dint1); // <- explicit std::cout<<"10 = "; ddouble = dint2; // <- implicit : WHY ?!?! return 0; } The last line worry me. Is it ok with the C++ standard ? Is it a bug of g++ ?

    Read the article

  • c++ design question: Can i query the base classes to find the number of derived classes satisfying a

    - by vivekeviv
    I have a piece of code like this class Base { public: Base(bool _active) { active = _active; } void Configure(); void Set Active(bool _active); private: bool active; }; class Derived1 : public Base { public: Derived1(bool active):Base(active){} }; similarly Derived 2 and Derived 3 Now if i call derived1Object.Configure, i need to check how many of the derived1Obj, derived2Obj,derived3Obj is active. Should i add this in the "Base" class like a function say, GetNumberOfActive()? And If the implementation is like this: class Imp { public: void Configure() { //Code instantiating a particular Derived1/2/3 Object int GetNumberOfActiveDerivedObj(); baseRef.Configure(int numberOfActiveDerivedClasses); } prive: Derived1 dObj1(true); Derived2 dObj2(false); Derived3 dObj3(true); }; should i calculate the numberOfActive Derived Objects in Imp Class? THanks

    Read the article

  • How to find out if an object's type implements IEnumerable<X> where X derives from Base using Reflec

    - by Dave Van den Eynde
    Give a base class "Base", I want to write a method Test, like this: private static bool Test(IEnumerable enumerable) { ... } such that Test returns true if the type of o implements any interface of IEnumerable where X derives from Base, so that if I would do this: public static IEnumerable<string> Convert(IEnumerable enumerable) { if (Test(enumerable)) { return enumerable.Cast<Base>().Select(b => b.SomePropertyThatIsString); } return enumerable.Cast<object>().Select(o => o.ToString()); } ...that it would do the right thing, using Reflection. I'm sure that its a matter of walking across all the interfaces of the type to find the first that matches the requirements, but I'm having a hard time finding the generic IEnumerable< among them. Of course, I could consider this: public static IEnumerable<string> Convert(IEnumerable enumerable) { return enumerable.Cast<object>().Select(o => o is Base ? ((Base)o).SomePropertyThatIsString : o.ToString()); } ...but think of it as a thought experiment.

    Read the article

  • Spring.net is not injecting chained base class properties!

    - by JohnIdol
    I am successfully injecting base class properties with spring.net with just a class that inherits from a base abstract class. Lets say Class MyClass : MyBase, and I am successfully setting a property like this: <object id="myInstantiableClass" type="myAssembly.MyClass myAssenbly" abstract="true"> <property name="MyBaseClassProperty" ref="anotherObjRef"></property> </object> Where MyBaseClassProperty is a property on the base class. Now I have another abstract class between the old base class and the instantiable class, and I am trying to set properties on both the abstract classes. So MyClass : MyNewBaseClass, and MyNewBaseClass : MyBaseClass. I have an additional property on the new base class (MyNewBaseClassProperty) and I am trying to inject it like this: <object id="myInstantiableClass" type="myAssembly.MyClass myAssenbly" abstract="true"> <property name="MyBaseClassProperty" ref="anotherObjRef"></property> <property name="MyNewBaseClassProperty" ref="someOtherObjRef"></property> </object> The property on the old base class is being injected but the one on the new one is not - and I am not getting an error or anything (so I am pretty sure my config is good), that property is just null! Any help appreciated! P.S. I am on asp.net (not MVC) but I don't think it's related.

    Read the article

  • NoSQL s'ouvre aux plateformes mobiles, Couchbase Mobile 1.0, la première base de données NoSQL native pour mobile sort

    NoSQL s'ouvre aux plateformes mobiles Couchbase Mobile 1.0, la première base de données NoSQL native pour mobile sortCouchbase, l'une des principales entreprises IT qui ont fait la promotion du NoSQL a récemment annoncé la sortie de son nouveau produit Couchbase Mobile 1.0, une solution pour tirer parti de la puissance du NoSQL à partir d'une plateforme mobile, but de la manoeuvre : promouvoir les applications mobiles NoSQL et conquérir un nouveau marché.Couchbase Mobile qui se décline comme étant...

    Read the article

  • What methods of requirements elicitation are suitable when I do not have direct access to the user base?

    - by metadice
    I am working on an application to create invoices. There are some features that are required based on the type of the application and are common to all invoice applications. However, we still need to determine what unique needs the user base might have. We do not have direct access to the users to obtain requirements or user stories. What techniques are most suitable for eliciting high-quality requirements from users when direct or frequent access is not possible?

    Read the article

  • Xamarin 3 disponible en téléchargement, permet la construction d'UIs natives iOS, Android et Windows depuis une seule base de code commune en C#

    Xamarin 3 disponible en téléchargement, permet la construction d'UIs natives iOS, Android et Windows depuis une seule base de code commune en C# La troisième mouture de l'environnement de développement mobile multiplateformes Xamarin est désormais disponible. Parmi les nouveautés qui accompagnent cette version figure l'arrivée de Xamarin Designer pour iOS, un puissant outil de conception visuel pour la plateforme iOS qui permettra aux développeurs de mettre rapidement sur pied des interfaces...

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >