I have just started learning MVVM and having a dilemna.
If I have a a main ViewModel and inside this model I have a number of datasets. Now should I be creating a new ViewModel for each row inside the dataset? Or expose the DataSet itself as a DependencyProperty?
For now the dataset has about 20 rows inside it, and the thought of itera...
How would I set focus to a textbox without specifying the name for that textbox? At the moment I am doing the following
<Window FocusManager.FocusedElement="{Binding ElementName=Username}">
<Grid>
<TextBox Text="{Binding Username}" Name="Username" />
</Grid>
</Window>
Is there any way of doing this without ...
Hi...In Rails, is it ok to define logic in a controller with a model. For example, take there is an User Model, which is good design.
1)Leaving the UserModel with the CRUD models and moving all the other User Specific actions to a separate controller or
2)Add the user specific actions to the same UserModels
Thanks :)
...
I've just started a new job and one of the things my new boss talked to me about was code longevity.
I've always coded to make my code infinently extensible and adaptable. I figured that if someone was going to change my code in the future then it should be easy to do.
But I never really had a clear idea on how far into the future tha...
Hi!
Im the kinda of android developer thats fascinated with good looking tabs. Probably the best one ive seen so far is the one from the GoWalla app.
Does anyone have some initial thoughts about how they achieved that look?
Thanks
...
I have a situation where I need to perform several small (but similar) tasks. I can think of two ways to achieve this.
First Approach:
function doTask1();
function doTask2();
function doTask3();
function doTask4();
Second Approach:
// TASK1, TASK2, ... TASK4 are all constants
function doTask(TASK) {
switch(TASK) {
case ...
A few mistakes and general childishness in early adulthood have left me in a situation where I work a menial job, with no possibility (in the near future) of attending school. I aspire to one day work in the programming field (gaming specifically), after proving myself on the indie end of things.
I've gotten very confident in C++, ja...
is it wasteful/bad design to use a vector/list where in most instances it will only have one element?
example:
class dragon
{
ArrayList<head> = new ArrayList<head> Heads;
tail Tail = new tail();
body Body = new body();
dragon()
{
theHead=new head();
Heads.add(theHead);
}
void nod()
{
...
I have two arraylists, and I would like to have a new arraylist with only the uncommon items.
Is this the "best" or at least decent way to do it?
Public Function diffLists(ByRef first, ByRef second As Collection) As ArrayList
Dim retval As New ArrayList()
For Each element In first
If Not second.Contains(element) Then
...
So I need to read flags in bits and set flags in bits. These bits are in various sizes of integer: int16, int32, int64, etc.
I would like to have a function that does something like this:
static integertype function(integertype data, char startbit, char endbit);
I don't want to code what will be the same code to isolate bits from for...
Hi,
I'm trying to write a ruby class that works similarly to rails activerecord model in the way that attributes are handled:
class Person
attr_accessor :name, :age
# init with Person.new(:name => 'John', :age => 30)
def initialize(attributes={})
attributes.each { |key, val| send("#{key}=", val) if respond_to?("#{key}=") }
...
Sometime back while designing something that included user management, I was required to have created_by and last_updated_by columns in the User table. To me it seemed a good idea to have a 1:1 relationship on User itself as it would serve as an additional check.
The obvious issue is creating the first user who will have to create himse...
In terms of "good code", is it acceptable to combine set and get methods into one? Like this:
public function dir($dir=null) {
if (is_null($dir)) return $this->dir;
$this->dir = $dir;
}
...
Which is a better programming practice and why?
I have a class like this:
class data {
public double time { get; internal set; }
public double count { get; internal set; }
public average_count { ... }
}
Where average_count should be read_only and give a calculation of count / time.
Is it better to write the accessor as...
I am an engineering student, not computer science though, and have been coding in Matlab for like 4 years. However only recently I have experienced writing long codes, or the need for connection of some multiple codes and data. Writing the code in bits as general functions is one of the things I have experienced lately is a good thing to...
I want to turn an array or list of ints into a comma delimited string, like this:
string myFunction(List<int> a) {
return string.Join(",", a);
}
But string.Join only takes List<string> as the second parameter. What is the best way to do this?
...
Sorry all,
I do have this mini table with 3 columns but, I will list the values either by one or other column.
1) Is it ok to have two of those columns with indexes?
2) Should we have only one index per table?
3) At the limit, if we have a table with 100 columns for example, and we have 50 of them with indexes, is this ok?
Thanks...
Hi,
Today I implemented a small piece of code that include analytics only in production environment using something like:
<% if Rails.env.production? %>
analytics here
<% end %>
I don't see anything wrong about it... however one of my c0-workers told me that it wasn't a good practice at all, that it would for sure introduce proble...
I have a large data set that is updated once a day. I am caching the results of an expensive query on that data but I want to update that cache each day. I am considering using CacheItemRemovedCallback to reload my cache on a daily interval, but I had the following concerns:
Isn't it possible that the CacheItemRemovedCallback could be ...
Considering I have a service to calculate a customer account balance with the interface
public interface ICustomerAccountCalculation
{
Decimal Balance(int customerId);
}
is it better style to rather than pass in the customer id to pass the customer object like this
public interface ICustomerAccountCalculation
{
Decimal Balanc...