code-reuse

Reusing SQLAlchemy models across projects

萝らか妹 提交于 2019-11-30 09:44:57
I have some standard SQLAlchemy models that I reuse across projects. Something like this: from sqlalchemy import Column, Integer, String, Unicode from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Category(Base): __tablename__ = 'category' id = Column(Integer, primary_key=True) slug = Column(String(250), nullable=False, unique=True) title = Column(Unicode(250), nullable=False) def __call__(self): return self.title I'd like to put this in a shared library and import it into each new project instead of cutting and pasting it, but I can't, because the

Make reference to C# code from multiple projects

二次信任 提交于 2019-11-30 09:01:50
问题 I have a .cs file full of C# code I keep reusing in multiple projects. Right now I'm including it in these projects by copying and pasting the code into a new file in each project directory. This is the wrong way to do it. What's the right way to do it? The right way should: keep the common code in only one place on my computer and keep the link fresh --- so when the common code changes, each project is aware of it, the next time I recompile that project. Randomly guessing, I'd expect some

Android Layout: Is reusable component UI possible?

泄露秘密 提交于 2019-11-30 07:58:00
问题 I'll preface this with, I've just started learning Android so be gentle. I come from an ASP.NET / Silverlight background so I was looking for something along the lines of controls. I want to reuse a layout (a ListView item template) in other layouts. Such that in my other layouts I can just add <myListItem /> to show it. Is this, or anything like it possible? or are there better ways? 回答1: This is very possible; you just need to use the <include /> tag. Basically, you put your layout in a

Split one big XAML in number of Sub-XAML files

 ̄綄美尐妖づ 提交于 2019-11-30 06:17:36
In my WPF4 Desktop-based application there is a big block with sidebar menu that repeats in each window and takes about 70 lines of XAML. In order to improve code reuse, I would like to split XAML file in two files: XAML-file that contains code for sidebar menu (≈70 lines) Base XAML file that contains «include/reference» to XAML-file with sidebar menu code As I understood, there are two ways to implement my problem: Use ResourceDictionary Use UserControl / CustomControl My questions are: What is the difference between ResourceDictionary and UserControl ? Could you give me examples where I have

Library for both iOS and OS X apps? [closed]

人走茶凉 提交于 2019-11-30 01:04:48
For a while now I have been killing spare time by creating a 2D game programming toolkit/library. It is written in Objective C, and consists of an OpenGL rendering system and a whole bunch of AI, physics code, a bunch of specialized containers and other game related stuff. Apart from the OpenGL based View mechanism (obviously), most of this code should be easily portable to iOS since it only uses the Foundation Framework and that framework appears to be implemented on iOS. So far I have only been testing the various components using a Cocoa NSOpenGLView but now I want to create a OS X/iOS

How can I write reusable Javascript?

柔情痞子 提交于 2019-11-29 20:43:10
I've started to wrap my functions inside of Objects, e.g.: var Search = { carSearch: function(color) { }, peopleSearch: function(name) { }, ... } This helps a lot with readability , but I continue to have issues with reusabilty . To be more specific, the difficulty is in two areas: Receiving parameters . A lot of times I will have a search screen with multiple input fields and a button that calls the javascript search function. I have to either put a bunch of code in the onclick of the button to retrieve and then martial the values from the input fields into the function call, or I have to

Logic code reuse between apps for Android and other platforms: To ContentProvider or not to ContentProvider?

不打扰是莪最后的温柔 提交于 2019-11-29 14:30:48
I'm developing an app which I want to make available both for Android and Blackberry (possibly to JavaME in the future). The business logic will be common to all the platforms - and hence, so will the corresponding layer in code. But I also have a data layer - which will obviously be different to the various platforms. My approach to this is to have a bean and an abstract DataStore class. If I were using Android's NotePad sample, it would look like this: Note Bean: public class Note { private long id; private String title; private String note; private long created; private long modified; /

Reusing SQLAlchemy models across projects

馋奶兔 提交于 2019-11-29 13:49:51
问题 I have some standard SQLAlchemy models that I reuse across projects. Something like this: from sqlalchemy import Column, Integer, String, Unicode from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Category(Base): __tablename__ = 'category' id = Column(Integer, primary_key=True) slug = Column(String(250), nullable=False, unique=True) title = Column(Unicode(250), nullable=False) def __call__(self): return self.title I'd like to put this in a shared library

Make reference to C# code from multiple projects

柔情痞子 提交于 2019-11-29 10:31:55
I have a .cs file full of C# code I keep reusing in multiple projects. Right now I'm including it in these projects by copying and pasting the code into a new file in each project directory. This is the wrong way to do it. What's the right way to do it? The right way should: keep the common code in only one place on my computer and keep the link fresh --- so when the common code changes, each project is aware of it, the next time I recompile that project. Randomly guessing, I'd expect some sort of directive like using mycode = C:\common\mycode.cs , but I'm sure that's not the .NET way of doing

Split one big XAML in number of Sub-XAML files

£可爱£侵袭症+ 提交于 2019-11-29 06:02:13
问题 In my WPF4 Desktop-based application there is a big block with sidebar menu that repeats in each window and takes about 70 lines of XAML. In order to improve code reuse, I would like to split XAML file in two files: XAML-file that contains code for sidebar menu (≈70 lines) Base XAML file that contains «include/reference» to XAML-file with sidebar menu code As I understood, there are two ways to implement my problem: Use ResourceDictionary Use UserControl / CustomControl My questions are: What