encapsulation

How to design a returned stream that may use skip

一笑奈何 提交于 2019-12-08 21:44:35
I have created a parsing library that accepts a provided input and returns a stream of Records. A program then calls this library and processes the results. In my case, my program is using something like recordStream.forEach(r -> insertIntoDB(r)); One of the types of input that can be provided to the parsing library is a flat file, which may have a header row. As such, the parsing library can be configured to skip a header row. If a header row is configured, it adds a skip(n) element to the return, e.g. Files.lines(input)**.skip(1)**.parallel().map(r -> createRecord(r)); The parsing library

What's the point of get and set methods [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-12-08 13:54:03
问题 This question already has answers here : Set and Get Methods in java? (15 answers) Closed 5 years ago . In my CS class I am just learning about classes and OOP. So when you create a class you initialize a certain number of private variable. I know you make them private because if they were public they would be easily changeable and could lead to a lot of bugs. So we use get and set methods to change the variable. But that once again makes the variables very easy to change right? So whats the

Encapsulate std::map to allow iterating, but no direct key access? [duplicate]

我是研究僧i 提交于 2019-12-08 10:56:34
问题 This question already has answers here : Prevent direct access to std::map keys (2 answers) Closed last year . Is there a way to encapsulate std::map within a user-defined class, allowing iteration, but not allowing direct access to the key? I would like to manipulate the key upon insertion and I want to force all access to elements through a user-defined method (as the key will need to be modified). I think the problem is allowing iterating over the map, whilst preventing the user from

What is the most common way to handle string names for Notifications and UserDefaults key names

只愿长相守 提交于 2019-12-08 06:56:54
问题 I will be using a few string names throughout my app for my Notifications and UserDefault names. I have heard that for type safety it's a good practice to define your notification names or UserDefaults key names as static strings and make them part of a class or struct. What is the most common way to handle string names for your Notification and UserDefault names? I have thought about putting them in my AppDelgate class as global variables as follow... let MY_STRING_NAME = "My string name"

using another object's functionality following a proper OO design - encapsulation

好久不见. 提交于 2019-12-08 03:59:45
问题 I am debating the proper, OO-design to use another object's functionality (methods) from a java class, while both objects remain decoupled as much as possible. For example, at some point in my class, to implement my logic, I need to call a method that belongs to another object, say a helper class. This helper class does not need to be in any way related to my original class, it just has a specific method which is visible to, and available for my class to use. After the logic is implemented,

Is there a Tomcat-like classloader that can be used standalone?

空扰寡人 提交于 2019-12-08 02:53:14
问题 I'm working with a Java sort-of-application-server (Smartfox) which can run multiple applications ("extensions") but has a very inconvenient classpath setup to go along with it, along with issues when trying to use SLF4J. To work around that I'd like to wrap my applications in their own classloaders. Such a containing classloader should be much like Tomcat's, in that it Can load classes from a directory containing JARs. Prefers classes from its own classpath over those from the parent Is

Is there a way to make a value accessible only to the parent of a nested class VB.NET?

帅比萌擦擦* 提交于 2019-12-08 02:25:51
问题 In general, according to the OOP paradigm, my understanding of encapsulation basically says: If a member is private, it can only be accessed by the class. If a member is protected, it can only be accessed by the base class and any derived classes. If a member is public, it can be accessed by anyone. If I have a nested class, can I declare a property to be accessible only to that class and the parent class it's nested within? For example: Public Class ContainerClass Public Class NestedClass

How to encapsulate database access?

六眼飞鱼酱① 提交于 2019-12-07 12:29:03
问题 I am developing a transactional application in .NET and would like to get some input on how to properly encapsulate database access so that: I don't have connection strings all over the place Multiple calls to the same stored procedure from different functions or WORSE, multiple stored procedures that are different by a single column I am interested in knowing if using an ORM like NHibernate is useful, as it may just add another layer of complexity to a rapidly changing data model, and

Javascript scope referencing outer object

蹲街弑〆低调 提交于 2019-12-07 12:03:25
问题 Basically, I use a meta-class framework called Joose for Javascript that allows me to make use of a more elegant class syntax - but I don't know how I might go about referencing the scope of the object from within deeper methods of the class declaration. I also use require.js for dependemcy management... Here's an example class definition: define([ 'jquery', 'handlebars', ], function($, Handlebars){ var MyClass = Class("MyClass", { //inheritance isa: SuperClass, //instance vars has: { hello:{

Celery dynamic tasks / hiding Celery implementation behind an interface

走远了吗. 提交于 2019-12-07 08:50:57
问题 I am trying to figure out how to implement my asynchronous jobs with Celery, without tying them to the Celery implementation. If I have an interface that accepts objects to schedule, such as callables (Or an object that wraps a callable): ITaskManager(Interface): def schedule(task): #eventually run task And I might implement it with the treading module: ThreadingTaskManager(object) def schedule(task): Thread(task).start() # or similar But it seems this couldn't be done with celery, am I right