leaky-abstraction

C++: push_back in std::vector while iterating it

北战南征 提交于 2020-06-14 05:50:34
问题 Following code snippet provides a very weird output. I was expecting an overflow( Python gives a MemoryError) #include <iostream> #include <vector> int main() { std::vector<int> a{1,2,3}; for( auto const & item : a) a.push_back(item); for( auto const & item : a) std::cout<<item<<','; return 0; } Output: 1,2,3,1,0,3, How do I interpret this result? If you do a similar thing in Python, it gives a memory error. >>> a = range(0,20) >>> for i in a: a.append(i) Traceback (most recent call last):

N-layered database application without using an ORM, how does the UI specify what it needs of data to display?

百般思念 提交于 2020-01-01 05:20:07
问题 I'm looking for pointers and information here, I'll make this CW since I suspect it has no single one correct answer. This is for C#, hence I'll make some references to Linq below. I also apologize for the long post. Let me summarize the question here, and then the full question follows. Summary: In a UI/BLL/DAL/DB 4-layered application, how can changes to the user interface, to show more columns (say in a grid), avoid leaking through the business logic layer and into the data access layer,

Fluent interfaces and leaky abstractions

百般思念 提交于 2020-01-01 04:18:10
问题 What is a fluent interface? I can't find a good definition of this, but all I get are long code examples in a language I am not very familiar with (e.g. C++). Also, what is a leaky abstraction? Thanks 回答1: A fluent interface is an API that allows you to write code that reads more or less like normal English. For example: Find.All.Questions(Where.IsAnswered == true); Method-chaining is usually used as part of the implementation, but there is more to it than that. To quote Fowler: I've also

Is clojure.lang really just implementation details?

陌路散爱 提交于 2019-12-23 12:56:06
问题 In Clojure, some tasks (such as instantiating a PersistentQueue or using deftype to implement a custom data type that is compatible with the clojure.core functions) require knowledge of the classes and/or interfaces in clojure.lang. However, according to clojure.lang/package.html: The only class considered part of the public API is clojure.lang.IFn. All other classes should be considered implementation details. Are these statements incorrect or outdated? If so, are there plans to correct them

Should I use integer ID or pointers for my opaque objects?

烂漫一生 提交于 2019-12-12 11:01:50
问题 I'm writing an abstraction layer on top of some graphics API (DirectX9 and DirectX11) and I would like your opinion. Traditionally I would create a base class for each concept I want to abstract. So in typical OO fashion I would have for example a class Shader and 2 subclasses DX9Shader and DX11Shader. I would repeat the process for textures, etc... and when I need to instantiate them I have an abstract factory that will return the appropriate subclass depending on the current graphics API.

Meaning of Leaky Abstraction?

柔情痞子 提交于 2019-12-03 01:46:56
问题 What does the term "Leaky Abstraction" mean? (Please explain with examples. I often have a hard time grokking a mere theory.) 回答1: Here's a meatspace example: Automobiles have abstractions for drivers. In its purest form, there's a steering wheel, accelerator and brake. This abstraction hides a lot of detail about what's under the hood: engine, cams, timing belt, spark plugs, radiator, etc. The neat thing about this abstraction is that we can replace parts of the implementation with improved

Meaning of Leaky Abstraction?

喜夏-厌秋 提交于 2019-12-02 17:02:22
What does the term "Leaky Abstraction" mean? (Please explain with examples. I often have a hard time grokking a mere theory.) Here's a meatspace example: Automobiles have abstractions for drivers. In its purest form, there's a steering wheel, accelerator and brake. This abstraction hides a lot of detail about what's under the hood: engine, cams, timing belt, spark plugs, radiator, etc. The neat thing about this abstraction is that we can replace parts of the implementation with improved parts without retraining the user. Let's say we replace the distributor cap with electronic ignition, and we