dry

Generating WAR and EAR artifacts inside the same Gradle project

删除回忆录丶 提交于 2020-01-02 05:46:20
问题 Suppose that I have a Gradle web project with a standard web project layout src/main/webapp . Project myproject-web , build.gradle : apply plugin: 'java' apply plugin: 'eclipse-wtp' apply plugin: 'war' I know that I can wrap the resulting .war file generated by myproject-web inside an .ear if I define a secondary project (say, myproject-ear ) which applies the ear plugin and references myproject-web as a dependency: Project myproject-ear , build.gradle : deploy project(':myproject-web') I

Does Android Content Provider authority definition break the DRY rule?

夙愿已清 提交于 2020-01-01 17:13:38
问题 Android's Content Provider must have: At least one authority must be specified. So for example in Google's samples android-BasicSyncAdapter AndroidManifest.xml there is <provider android:name=".provider.FeedProvider" android:authorities="com.example.android.basicsyncadapter" android:exported="false" /> Then to implement this CP one need to define the same String inside the CP like in android-BasicSyncAdapter FeedProvider.java CONTENT_AUTHORITY public static final String CONTENT_AUTHORITY =

Does Android Content Provider authority definition break the DRY rule?

99封情书 提交于 2020-01-01 17:13:15
问题 Android's Content Provider must have: At least one authority must be specified. So for example in Google's samples android-BasicSyncAdapter AndroidManifest.xml there is <provider android:name=".provider.FeedProvider" android:authorities="com.example.android.basicsyncadapter" android:exported="false" /> Then to implement this CP one need to define the same String inside the CP like in android-BasicSyncAdapter FeedProvider.java CONTENT_AUTHORITY public static final String CONTENT_AUTHORITY =

setattr and getattr with methods

百般思念 提交于 2020-01-01 10:27:47
问题 I have a boiler platey class that delegates some actions to a reference class. It looks like this: class MyClass(): def __init__(self, someClass): self.refClass = someClass def action1(self): self.refClass.action1() def action2(self): self.refClass.action2() def action3(self): self.refClass.action3() This is the refClass: class RefClass(): def __init__(self): self.myClass = MyClass(self) def action1(self): #Stuff to execute action1 def action2(self): #Stuff to execute action2 def action3(self

How do you share configuration information or business rules between languages

坚强是说给别人听的谎言 提交于 2019-12-28 15:34:29
问题 I'm looking for best practices for using the same data in different places without repeating yourself - this could include configuration or business rules. Example 1. Data validation rules where you want to validate on the client using javascript, but you want to make sure by validating on the server. Example 2. Database access where your web server and your cronjobs use the same password, username. Ease of processing and a human-readable solution would be a plus. 回答1: Encode your data in

How to apply the DRY principle to SQL Statements that Pivot Months

佐手、 提交于 2019-12-24 19:16:00
问题 I'm wondering how others handle this situation... and how to apply the Don't Repeat Yourself (DRY) principle to this situation. I find myself constantly PIVOTing or writing CASE statements in T-SQL to present Months as columns. I generally have some fields that will include (1) a date field and (2) a value field. When I present this back to a user through an ASPX page or Reporting Services I need to have the last right-most 14 columns to have this pattern: [Year],[Jan],[Feb],[Mar],[Apr],[May]

Variable value assignment operation duplication

淺唱寂寞╮ 提交于 2019-12-24 09:26:01
问题 Context From The Pragmatic Programmer : Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. Questions How is that statement reconciled with directly setting a private member variable's value throughout a class in multiple places? Does it matter as there can be no external dependencies on the value? Is it duplication to directly change private member variables that have public accessors in other places besides the accessor? Example Consider

How not to repeat yourself across projects and/or languages

怎甘沉沦 提交于 2019-12-24 06:44:52
问题 I'm working on several distinct but related projects in different programming languages. Some of these projects need to parse filenames written by other projects, and expect a certain filename pattern. This pattern is now hardcoded in several places and in several languages, making it a maintenance bomb. It is fairly easy to define this pattern exactly once in a given project, but what are the techniques for defining it once and for all for all projects and for all languages in use? 回答1:

Keeping DRY between Javascript and CSS

ⅰ亾dé卋堺 提交于 2019-12-23 23:14:15
问题 Say you've got a menu that toggles open and closed with a button. My standard way of going about this would be to write the CSS for a closed menu, and write Javascript that specifies (or animates to) an open menu state. Lately I've gotten into Active.js, a client-side MVC framework. It provides for view classes with builders for making DOM fragments, and those fragments can be given methods that handle things like animation and DOM state. Something feels wonky about describing the initial

Load YAML nested with Jinja2 in Python

天大地大妈咪最大 提交于 2019-12-23 09:18:17
问题 I have a YAML file ( all.yaml ) that looks like: ... var1: val1 var2: val2 var3: {{var1}}-{{var2}}.txt ... If I load it in Python like this: import yaml f = open('all.yaml') dataMap = yaml.safe_load(f) f.close() print(dataMap["var3"]) the output is {{var1}}-{{var2}}.txt and not val1-val2.txt . Is it possible to replace the nested vars with the value? I tried to load it with: import jinja2 templateLoader = jinja2.FileSystemLoader( searchpath="/path/to/dir" ) templateEnv = jinja2.Environment(