code-reuse

How can I reuse code when two different wicket applications share common functionality

99封情书 提交于 2019-12-07 07:14:25
I have a Wicket AuthenticatedWebApplication which has several pages and features that need to be reused in a new AuthenticatedWebApplication that I have to develop. I am using Wicket 1.4, Spring and Hibernate. Both applications will even share the same look (except for Application logo) which is now implemented in a base page. Has anyone had a similar experience? I definitely don't want to recur to copy-paste code because the common functionality implements a workflow process which can and will change. What can I do to keep my applications modular, and achieve my goal? My company does this all

Does LINQ-to-SQL Support Composable Queries?

前提是你 提交于 2019-12-07 04:38:08
问题 Speaking as a non-C# savvy programmer, I'm curious as to the evaluation semantics of LINQ queries like the following: var people = from p in Person where p.age < 18 select p var otherPeople = from p in people where p.firstName equals "Daniel" select p Assuming that Person is an ADO entity which defines the age and firstName fields, what would this do from a database standpoint? Specifically, would the people query be run to produce an in-memory structure, which would then be queried by the

ImportError: No Module Named <parent dir>

久未见 提交于 2019-12-06 19:10:32
问题 I am trying to learn programming through Python, so I apologize in advance if this is an absurdly simple question. I am attempting to simplify my convoluted directory structure and utilize some of Python's code-reuse features, I have encountered what is for me an inexplicable ImportError error. For the past several hours I've been reading about Python's import , module , and package features (here, here, here, and here among others), yet I remain unable to solve this (seemingly) simple error.

Android: Custom Clock widget Service work-around?

落爺英雄遲暮 提交于 2019-12-06 12:03:16
I was interested in developing a clock widget for the homescreen and upon reading Home Screen Widgets tutorial , I wondered if there is a pre-existing Service I could reference for updating the current time rather than re-inventing the wheel? I download the Retro Clock application on my android phone and noticed that when I click it, it pops up the Alarm Clock settings, but with the default Google Analog Clock widget, upon click does nothing. Is that because the Retro Clock widget implements the Alarm Clock service? If so, how can I go about referencing that service? Or do I have this all

Architecture of some reusable code

≯℡__Kan透↙ 提交于 2019-12-06 11:01:35
I am writing a number of small, simple applications which share a common structure and need to do some of the same things in the same ways (e.g. logging, database connection setup, environment setup) and I'm looking for some advice in structuring the reusable components. The code is written in a strongly and statically typed language (e.g. Java or C#, I've had to solve this problem in both). At the moment I've got this: abstract class EmptyApp //this is the reusable bit { //various useful fields: loggers, db connections abstract function body() function run() { //do setup this.body() //do

How do you foster the use of shared components in your organization?

一笑奈何 提交于 2019-12-06 07:57:00
问题 If your company or project places an emphasis on (or at least appreciates) the development of code and components that can be reused and shared across projects, what are the "social engineering" things you've needed to do to facilitate the re-use the code? In my experience, code or components that are simply stated as being "reusable" won't be reused unless that code has someone to champion or evangelize it. Otherwise, people simply won't know about it. How do you make sure shared components

Is there a way to reuse data annotations?

老子叫甜甜 提交于 2019-12-06 07:23:04
问题 Is there a way to implement the idea of a data domains (at a property level) inside of a class that is used as a model in a view in ASP.Net MVC 4? Consider this code: public class LoginProfileModel { [DisplayName("Login ID")] [Required(ErrorMessage = "Login ID is required.")] public string LogonID { get; set; } [DisplayName("Password")] [Required(ErrorMessage = "Password cannot be blank.")] [StringLength(20, MinimumLength = 3)] [DataType(DataType.Password)] public string Password { get; set;

Simple C/C++ library for triangle-intersection acceleration structure

两盒软妹~` 提交于 2019-12-06 06:35:14
问题 I'm raytracing and would like to speed it up via some acceleration structure (kd-tree, BVH, whatever). I don't want to code it up myself. What I've tried so far: Yanking the kd-tree out of pbrt. There are so many intra-dependencies that I couldn't succeed at this without pulling all of pbrt into my code. CGAL's AABB tree. Frustratingly, this seems to return only the point of intersection. Without knowing which triangle the point came from, I can't efficiently interpolate color over the

Switching between two datasets in this d3.js reusable and zoomable line chart

拈花ヽ惹草 提交于 2019-12-06 06:10:59
In this example http://bl.ocks.org/4743409 I set up a zoomable line chart containing two lines. But Switching the selection options I obtain a superposition of the two datasets. How can I switch between the two? Thank you in advance for your help and most of all for your suggestions to improve the code. UPDATE: I succeeded in implementing a reusable chart (and I updated the example in the link). Now I have no superposition of the two datasets. However, I still do not understand why the proper svg dimesions are only setted on update and not on the first creation. 来源: https://stackoverflow.com

Multiple apps with common code — how to approach this?

耗尽温柔 提交于 2019-12-06 05:56:08
问题 My company has two or three web apps that use a lot of common code -- a custom MVC framework, utility classes, JavaScript libraries, and so on. We'd prefer not to duplicate all this code in each app, because we end up with several slightly different versions of it in use. But we don't want the apps to require the same exact copy of this code, because we don't want an update to one app to potentially break another. Does anyone have any tips on dealing with this problem? I don't think I'm