abstraction

Abstract private functions

吃可爱长大的小学妹 提交于 2019-11-30 07:20:34
问题 The following code will have PHP unhappy that customMethod() is private. Why is this the case? Is visibility determined by where something is declared rather than defined? If I wanted to make customMethod only visible to boilerplate code in the Template class and prevent it from being overriden, would I just alternatively make it protected and final? Template.php: abstract class Template() { abstract private function customMethod(); public function commonMethod() { $this->customMethod(); } }

Should I extend ArrayList to add attributes that isn't null?

▼魔方 西西 提交于 2019-11-30 07:19:06
I would like to add a collection of objects to an arrayList ,only if the particular attribute is not null. I am thinking of extending the ArrayList and implementing the check inside the child class. One alternate way is to check for the the attribute before putting it in a Arraylist, but that would mean , i will have to scatter the if checks every where if i need to add the objects to the arraylist based on the logic. I would like to know your thoughts on it ... on a second thought is it a overkill ? Tomasz Nurkiewicz Decorator pattern I would actually recommend wrapping ArrayList using well

What's the difference between a sequence and a collection in Clojure

落爺英雄遲暮 提交于 2019-11-30 02:51:53
I am a Java programmer and am new to Clojure. From different places, I saw sequence and collection are used in different cases. However, I have no idea what the exact difference is between them. For some examples: 1) In Clojure's documentation for Sequence : The Seq interface (first coll) Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil. (rest coll) Returns a sequence of the items after the first. Calls seq on its argument. If there are no more items, returns a logical sequence for which seq returns nil. (cons item seq) Returns a new seq where

Wrapping DbSet<TEntity> with a custom DbSet/IDbSet?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 22:27:47
First off, I think this is somewhat ridiculous to do but the other members of my team insist upon it and I can't come up with a good argument against it other than "I think it's dumb"... What we're trying to do is create a completely abstract data layer and then have various implementations of that data layer. Simple enough, right? Enter Entity Framework 4.1... Our end goal here is that the programmers (I do my best to stay only on the data layer) never want to have to be exposed to the concrete classes. They only ever want to have to use interfaces in their code, aside from obviously needing

How much abstraction is too much?

久未见 提交于 2019-11-29 18:45:51
In an object-oriented program: How much abstraction is too much? How much is just right? I have always been a nuts and bolts kind of guy. I understood the concept behind high levels of encapsulation and abstraction, but always felt instinctively that adding too much would just confuse the program. I always tried to shoot for an amount of abstraction that left no empty classes or layers. And where in doubt, instead of adding a new layer to the hierarchy, I would try and fit something into the existing layers. However, recently I've been encountering more highly abstracted systems. Systems where

Interfaces (interface/abstract class) are not abstractions?

荒凉一梦 提交于 2019-11-29 12:40:37
问题 Of late, I have been reading posts which talks about the supposed wrong notion that interfaces are abstractions. One such post is http://blog.ploeh.dk/2010/12/02/InterfacesAreNotAbstractions.aspx I am a bit confused. If I don't have interfaces (interface/abstract class), then how will I inject my dependencies and mock them? Also, I have heard people talk about not using interfaces which has just one implementor. Like this blog here - http://simpleprogrammer.com/2010/11/02/back-to-basics-what

Safer compile-time String.format() alternative issue 2

倖福魔咒の 提交于 2019-11-29 12:36:57
With String.format , there seems to be a large opening for programmatic error that isn't found at compile-time. This can make fixing errors more complex and / or take longer. This was the issue for me that I set out to fix (or hack a solution). I came close, but I am not close enough. For this problem, this is more certainly over-engineered. I understand that, but I just want to find a good compile-time solution to this. More information can be found here. My question dealing with Basic Program 2 calculators. 1 Logic backend. Could be expanded to include other simple calculators. I wanted 1

Should I extend ArrayList to add attributes that isn't null?

南楼画角 提交于 2019-11-29 10:09:02
问题 I would like to add a collection of objects to an arrayList ,only if the particular attribute is not null. I am thinking of extending the ArrayList and implementing the check inside the child class. One alternate way is to check for the the attribute before putting it in a Arraylist, but that would mean , i will have to scatter the if checks every where if i need to add the objects to the arraylist based on the logic. I would like to know your thoughts on it ... on a second thought is it a

Command Pattern seems needlessly complex (what am I failing to understand?)

流过昼夜 提交于 2019-11-29 09:21:26
I've read up on the Command Pattern, and I think I'm missing something. The Command object exists to abstract away the details of the Receiver object. It seems to me that we could simply stop here, and hold references to Command objects to execute the appropriate method at the appropriate time. Why, then, is the Invoker needed? What advantage does this additional indirection provide? We've already hidden the details of the Receiver behind the Command, what's the motivation for the Command to then be hidden from the client as well? Well, if you put it that way, it seems quite complex, but often

Abstraction and abstract in java

末鹿安然 提交于 2019-11-29 07:03:24
I am a java developer with good understanding of Object orientation concepts( or maybe, I think like that ). And right now I am learning design patterns (From Head first design patterns). I have been reading about OOPS concept abstraction to understand it briefly, and reading more about it has made me more confusing than I earlier was. As I understand, abstraction refers to hiding the internal details of the program while exposing the interface to other programmers without worries of internal details. But, I don't understand How abstract classes fit into this concept of abstraction, where