abstraction

Generic return types from abstract/virtual methods

折月煮酒 提交于 2019-12-10 21:19:55
问题 I have a relationship between two base classes: public abstract class RecruiterBase<T> { // Properties declare here // Constructors declared here public abstract IQueryable<T> GetCandidates(); } public abstract class CandidateBase<T> { // Properties declare here // Constructors declared here } And their concrete implementations as such: public class CandidateA : CandidateBase<CandidateA> { // Constructors declared here } public class RecruiterA : RecruiterBase<RecruiterA> { // Constructors

Get Entity From Table Using Reflection From Abstract Type

非 Y 不嫁゛ 提交于 2019-12-10 19:24:53
问题 Ok, so I have an abstract class called Product. I have 3 tables called Items, Kits, and Packages that implement Product. Product has a public property that exposes the object's primary key. That said I have a form where I pass a product. I would would like to pull that product out of a fresh datacontext without having to write a big switch reflecting it's type to get its proper table. I wanted to do something like this but the cast bit won't accept foo. public BuilderInclusionsForm(Product p)

Demonstrate first-class functions in this simple example [closed]

这一生的挚爱 提交于 2019-12-10 17:45:55
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . Please demonstrate first-class functions (or some other functional programming concept) for code reuse for a beginner using these two overlapping Clojure functions. Basically, simplify the code block below using

Using Entity Framework with repository pattern in WinForms MDI

独自空忆成欢 提交于 2019-12-10 14:22:30
问题 We are about to start up a new project similar to a previous one. I could just copy the old design but I am not all too satisified with the old design. It is a "standard" business system (sales,stocktaking,warehousing etc) built ontop of .Net 3.5 (Winforms MDI) with Entity Framework in the backend. All forms inherit from a baseform (which inherits Windows.Form). The form exposes a property called ObjectContext, which on the first call instantiates a new ObjectContext. This makes up a pretty

How does abstraction helps in hiding the implementation details in Java?

你离开我真会死。 提交于 2019-12-10 12:17:34
问题 Abstraction is a process of hiding the implementation details and showing only functionality to the user. Another way, it shows only important things to the user and hides the internal details. So below is an example where an abstract class is made and abstract methods are overridden. But the thing i didn't understand is how it is hiding the implementation details? abstract class Bank { abstract int getRateOfInterest(); } class SBI extends Bank { int getRateOfInterest() { return 7; } } class

DataBinding: How to use BaseActivity / How to use Abstraction

主宰稳场 提交于 2019-12-10 02:34:47
问题 I am trying to add DataBinding to my app. In my app, I have a BaseActivity which has a Toolbar and a FrameLayout. FrameLayout is container for activities' which extend the BaseActivity. How can I add databinding to both my BaseActivity and the extending activities? I'll share my code without DataBinding: Here is my BaseActivity.java : public class BaseActivity extends AppCompatActivity { @Override public void setContentView(@LayoutRes int layoutResID) { LinearLayout container = (LinearLayout)

Is this a typical use case for IOC?

≯℡__Kan透↙ 提交于 2019-12-09 14:20:09
问题 My current application allows users to define custom web forms through a set of admin screens. it's essentially an EAV type application. As such, I can't hard code HTML or ASP.NET markup to render a given page. Instead, the UI requests an instance of a Form object from the service layer, which in turn constructs one using a several RDMBS tables. Form contains the kind of classes you would expect to see in such a context: Form => IEnumerable<FormSections> => IEnumerable<FormFields> Here's what

How to approach something complex?

南笙酒味 提交于 2019-12-09 11:24:51
问题 You know that particular part of your code that is essential for the project but will probably take a lot of time to get it done? Do you ever get the feeling that you'd rather work on something else (probably less important) or not code at all instead of working on that part? That beast you try so hard to avoid and use every lazy trick you know to delay its inevitable implementation? Now, I'm probably just being lazy, but I've always had to deal with code like that. Write something I don't

How Does One Make Scala Control Abstraction in Repeat Until?

末鹿安然 提交于 2019-12-09 05:44:15
问题 I am Peter Pilgrim. I watched Martin Odersky create a control abstraction in Scala. However I can not yet seem to repeat it inside IntelliJ IDEA 9. Is it the IDE? package demo class Control { def repeatLoop ( body: => Unit ) = new Until( body ) class Until( body: => Unit ) { def until( cond: => Boolean ) { body; val value: Boolean = cond; println("value="+value) if ( value ) repeatLoop(body).until(cond) // if (cond) until(cond) } } def doTest2(): Unit = { var y: Int = 1 println("testing ...

Use an enum to select which class to instantiate

送分小仙女□ 提交于 2019-12-08 19:21:11
问题 I have an enum that I am trying to associate to dto's: public enum DtoSelection { dto1, dto2, dto3, } There are 108 and values in this enum. I have a dto object for each of these dto's: public class dto1 : AbstractDto { public int Id { get; set; } //some stuff specific to this dto } I am trying to make a method (eventually a service) that will return me a new dto object of the type associated to the the dto in question: private AbstractDto(int id) { if (id == DtoSelection.Dto1.ToInt()) /