Search Results

Search found 2051 results on 83 pages for 'abstract'.

Page 16/83 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Call For Papers Tips and Tricks

    - by speakjava
    This year's JavaOne session review has just been completed and by now everyone who submitted papers should know whether they were successful or not.  I had the pleasure again this year of leading the review of the 'JavaFX and Rich User Experiences' track.  I thought it would be useful to write up a few comments to help people in future when submitting session proposals, not just for JavaOne, but for any of the many developer conferences that run around the world throughout the year.  This also draws on conversations I recently had with various Java User Group leaders at the Oracle User Group summit in Riga.  Many of these leaders run some of the biggest and most successful Java conferences in Europe. Try to think of a title which will sound interesting.  For example, "Experiences of performance tuning embedded Java for an ARM architecture based single board computer" probably isn't going to get as much attention as "Do you like coffee with your dessert? Java on the Raspberry Pi".  When thinking of the subject and title for your talk try to steer clear of sessions that might be too generic (and so get lost in a group of similar sessions).  Introductory talks are great when the audience is new to a subject, but beware of providing sessions that are too basic when the technology has been around for a while and there are lots of tutorials already available on the web. JavaOne, like many other conferences has a number of fields that need to be filled in when submitting a paper.  Many of these are selected from pull-down lists (like which track the session is applicable to).  Check these lists carefully.  A number of sessions we had needed to be shuffled between tracks when it was thought that the one selected was not appropriate.  We didn't count this against any sessions, but it's always a good idea to try and get the right one from the start, just in case. JavaOne, again like many other conferences, has two fields that describe the session being submitted: abstract and summary.  These are the most critical to a successful submission.  The two fields have different names and that is significant; a frequent mistake people make is to write an abstract for a session and then duplicate it for the summary.  The abstract (at least in the case of JavaOne) is what gets printed in the show guide and is typically what will be used by attendees when deciding what sessions to attend.  This is where you need to sell your session, not just to the reviewers, but also the people who you want in your audience.  Submitting a one line abstract (unless it's a really good one line) is not usually enough to decide whether this is worth investing an hour of conference time.  The abstract typically has a limit of a few hundred characters.  Try to use as many of them as possible to get as much information about your session across.  The summary should be different from the abstract (and don't leave it blank as some people do).  This field is where you can give the reviewers more detail about things like the structure of the talk, possible demonstrations and so on.  As a reviewer I look to this section to help me decide whether the hard-sell of the title and abstract will actually be reflected in the final content.  Try to make this comprehensive, but don't make it excessively long.  When you have to review possibly hundreds of sessions a certain level of conciseness can make life easier for reviewers and help the cause of your session. If you've not made many submissions for talks in the past, or if this is your first, try to give reviewers places to find background on you as a presenter.  Having an active blog and Twitter handle can also help reviewers if they're not sure what your level of expertise is.  Many call-for-papers have places for you to include this type of information.  It's always good to have new and original presenters and presentations for conferences.  Hopefully these tips will help you be successful when you answer the next call-for-papers.

    Read the article

  • Building a Repository Pattern against an EF 5 EDMX Model - Part 1

    - by Juan
    I am part of a year long plus project that is re-writing an existing application for a client.  We have decided to develop the project using Visual Studio 2012 and .NET 4.5.  The project will be using a number of technologies and patterns to include Entity Framework 5, WCF Services, and WPF for the client UI.This is my attempt at documenting some of the successes and failures that I will be coming across in the development of the application.In building the data access layer we have to access a database that has already been designed by a dedicated dba. The dba insists on using Stored Procedures which has made the use of EF a little more difficult.  He will not allow direct table access but we did manage to get him to allow us to use Views.  Since EF 5 does not have good support to do Code First with Stored Procedures, my option was to create a model (EDMX) against the existing database views.   I then had to go select each entity and map the Insert/Update/Delete functions to their respective stored procedure. The next step after I had completed mapping the stored procedures to the entities in the EDMX model was to figure out how to build a generic repository that would work well with Entity Framework 5.  After reading the blog posts below, I adopted much of their code with some changes to allow for the use of Ninject for dependency injection.http://www.tcscblog.com/2012/06/22/entity-framework-generic-repository/ http://www.tugberkugurlu.com/archive/generic-repository-pattern-entity-framework-asp-net-mvc-and-unit-testing-triangle IRepository.cs public interface IRepository : IDisposable where T : class { void Add(T entity); void Update(T entity, int id); T GetById(object key); IQueryable Query(Expression> predicate); IQueryable GetAll(); int SaveChanges(); int SaveChanges(bool validateEntities); } GenericRepository.cs public abstract class GenericRepository : IRepository where T : class { public abstract void Add(T entity); public abstract void Update(T entity, int id); public abstract T GetById(object key); public abstract IQueryable Query(Expression> predicate); public abstract IQueryable GetAll(); public int SaveChanges() { return SaveChanges(true); } public abstract int SaveChanges(bool validateEntities); public abstract void Dispose(); } One of the issues I ran into was trying to do an update. I kept receiving errors so I posted a question on Stack Overflow http://stackoverflow.com/questions/12585664/an-object-with-the-same-key-already-exists-in-the-objectstatemanager-the-object and came up with the following hack. If someone has a better way, please let me know. DbContextRepository.cs public class DbContextRepository : GenericRepository where T : class { protected DbContext Context; protected DbSet DbSet; public DbContextRepository(DbContext context) { if (context == null) throw new ArgumentException("context"); Context = context; DbSet = Context.Set(); } public override void Add(T entity) { if (entity == null) throw new ArgumentException("Cannot add a null entity."); DbSet.Add(entity); } public override void Update(T entity, int id) { if (entity == null) throw new ArgumentException("Cannot update a null entity."); var entry = Context.Entry(entity); if (entry.State == EntityState.Detached) { var attachedEntity = DbSet.Find(id); // Need to have access to key if (attachedEntity != null) { var attachedEntry = Context.Entry(attachedEntity); attachedEntry.CurrentValues.SetValues(entity); } else { entry.State = EntityState.Modified; // This should attach entity } } } public override T GetById(object key) { return DbSet.Find(key); } public override IQueryable Query(Expression> predicate) { return DbSet.Where(predicate); } public override IQueryable GetAll() { return Context.Set(); } public override int SaveChanges(bool validateEntities) { Context.Configuration.ValidateOnSaveEnabled = validateEntities; return Context.SaveChanges(); } #region IDisposable implementation public override void Dispose() { if (Context != null) { Context.Dispose(); GC.SuppressFinalize(this); } } #endregion IDisposable implementation } At this point I am able to start creating individual repositories that are needed and add a Unit of Work.  Stay tuned for the next installment in my path to creating a Repository Pattern against EF5.

    Read the article

  • 'undefined method init for Mysql:Class'

    - by sscirrus
    I've been having problems with a MySQL Server installation that got messed up after a power outage. Configuration Intel i5 Mac running OS X 10.6.5 Ruby 1.9.2 installed Rails 3.0.1 installed MySQL Server (finally) installed and running I completely reinstalled MySQL, which deleted the local development/test/production databases. So, I have run create database development; in MySQL to get the dev database ready for a migration. Current Goal Run rake db:migrate to get my databases back again. (I cannot currently access my databases or Mysql at all from Rails.) Error Using the gem 'mysql', '2.8.1' and run rake db:migrate, I get the error: rake aborted! undefined method 'init' for Mysql:Class Stack Trace: /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb:30:in 'mysql_connection' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in 'new_connection' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:238:in 'checkout_new_connection' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:194:in 'block (2 levels) in checkout' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in 'loop' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in 'block in checkout' /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:201:in 'mon_synchronize' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:189:in 'checkout' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in 'connection' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in 'retrieve_connection' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in 'retrieve_connection' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in 'connection' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/migration.rb:486:in 'initialize' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/migration.rb:433:in 'new' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/migration.rb:433:in 'up' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/migration.rb:415:in 'migrate' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/railties/databases.rake:142:in 'block (2 levels) in <top (required)>' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:636:in 'call' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:636:in 'block in execute' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:631:in 'each' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:631:in 'execute' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:597:in 'block in invoke_with_call_chain' /Users/sscirrus/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:201:in 'mon_synchronize' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:590:in 'invoke_with_call_chain' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:583:in 'invoke' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2051:in 'invoke_task' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in 'block (2 levels) in top_level' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in 'each' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2029:in 'block in top_level' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2068:in 'standard_exception_handling' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2023:in 'top_level' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2001:in 'block in run' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:2068:in 'standard_exception_handling' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:1998:in 'run' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/bin/rake:31:in '<top (required)>' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in 'load' /Users/sscirrus/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in '<main>'

    Read the article

  • Ruby on Rail using MYSQL database

    - by Joseph Misiti
    Hey guys, New to rails, trying to figure out something simple. Seems as though I cannot migrate a very simple mysql database using "rake db:migrate" command. Here is the issue: I know rails defaults to sqllite right now, but I need to use mysql for a series of reasons. Use the following commands rails -d mysql MyMoviesSQL cd MyMoviesSQL script/generate scaffold Movies title:string rating:integer rake db:migrate never get past here because i see the following error: in /Users/user/websites/MyMovieSQL) rake aborted! NoMethodError: undefined method `ord' for 0:Fixnum: SET NAMES 'utf8' (See full trace by running task with --trace) using trace XXXXX-macbook-pro:MyMovieSQL user$ rake db:migrate --trace (in /Users/user/websites/MyMovieSQL) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! NoMethodError: undefined method ord' for 0:Fixnum: SET NAMES 'utf8' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:inlog' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:in execute' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:599:inconfigure_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:594:in connect' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:203:ininitialize' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:75:in new' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:75:inmysql_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in send' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:innew_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in checkout_new_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:incheckout' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in loop' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:incheckout' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in synchronize' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:incheckout' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:inretrieve_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in retrieve_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:inconnection' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:435:in initialize' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:innew' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:in up' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:383:inmigrate' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:inload' /usr/bin/rake:19 no clue what is going on, if they want me to add a patch because the methods does not exist, please tell me which file to add it to, and also, how in the future do i figure out which file I need to patch (I see it looks like its a method in FixNum class) here is a patch to a problem that looks similar, but its a different version of ruby http://www.mail-archive.com/[email protected]/msg00250.html versions rails 2.3.5 ruby 1.8.6 gem list yeilds: * LOCAL GEMS * actionmailer (2.3.5, 1.3.6) actionpack (2.3.5, 1.13.6) actionwebservice (1.2.6) activerecord (2.3.5, 1.15.6) activeresource (2.3.5) activesupport (2.3.5, 1.4.4) acts_as_ferret (0.4.1) capistrano (2.0.0) cgi_multipart_eof_fix (2.5.0) daemons (1.0.9) dbi (0.4.3) deprecated (2.0.1) dnssd (0.6.0) fastthread (1.0.1) fcgi (0.8.7) ferret (0.11.4) gem_plugin (0.2.3) highline (1.2.9) hpricot (0.6) libxml-ruby (0.9.5, 0.3.8.4) mongrel (1.1.4) needle (1.3.0) net-sftp (1.1.0) net-ssh (1.1.2) rack (1.0.1) rails (2.3.5) rake (0.8.7, 0.7.3) RedCloth (3.0.4) ruby-openid (1.1.4) ruby-yadis (0.3.4) rubygems-update (1.3.6) rubynode (0.1.3) sqlite3-ruby (1.2.1) termios (0.9.4) thanks in advanced

    Read the article

  • Need help understanding Generics, How To Abstract Types Question.

    - by kmacmahon
    I could use some really good links that explain Generics and how to use them. But I also have a very specific question, relater to working on a current project. Given this class constructor: public class SecuredDomainViewModel<TDomainContext, TEntity> : DomainViewModel<TDomainContext, TEntity> where TDomainContext : DomainContext, new() where TEntity : Entity, new() public SecuredDomainViewModel(TDomainContext domainContext, ProtectedItem protectedItem) : base(domainContext) { this.protectedItem = protectedItem; } And its creation this way: DomainViewModel d; d = new SecuredDomainViewModel<MyContext, MyEntityType>(this.context, selectedProtectedItem); Assuming I have 20 different EntityTypes within MyContext, is there any easier way to call the constructor without a large switch statement? Also, since d is DomainViewModel and I later need to access methods from SecuredDomainViewModel, it seems I need to do this: if (((SecuredDomainViewModel<MyContext, MyEntityType>)d).CanEditEntity) But again "MyEntityType" could actually be one of 20 diffent types. Is there anyway to write these types of statements where MyEntityType is returned from some sort of Reflection?

    Read the article

  • Need help understanding Generics, How To Abstract Types Question.

    - by kmacmahon
    I could use some really good links that explain Generics and how to use them. But I also have a very specific question, relater to working on a current project. Given this class constructor: public class SecuredDomainViewModel<TDomainContext, TEntity> : DomainViewModel<TDomainContext, TEntity> where TDomainContext : DomainContext, new() where TEntity : Entity, new() And its creation this way: DomainViewModel d; d = new SecuredDomainViewModel<MyContext, MyEntityType>(this.context, selectedProtectedItem); Assuming I have 20 EntityTypes within MyContext, is there any easier way to call the constructor without a large switch statement? Also, since d is DomainViewModel and I want to access methods for SecuredDomainViewModel, it seems I need to do this: if (((SecuredDomainViewModel<MyContext, MyEntityType>)d).IsBusy) But again "MyEntityType" could actually be one of 20 types. Is there anyway to write these types of statements where MyEntityType is returned from some sort of Reflection?

    Read the article

  • abstract data type list. . .

    - by aldrin
    A LIST is an ordered collection of items where items may be inserted anywhere in the list. Implement a LIST using an array as follows: struct list { int *items; // pointer to the array int size; // actual size of the array int count; // number of items in the array }; typedef struct list *List; // pointer to the structure Implement the following functions: a) List newList(int size); - will create a new List and return its pointer. Allocate space for the structure, allocate space for the array, then initialize size and count, return the pointer. b) void isEmpty(List list); c) void display(List list); d) int contains(List list, int item); e) void remove(List list, int i) ; f) void insertAfter(List list,int item, int i); g) void addEnd(List list,int item) - add item at the end of the list – simply store the data at position count, then increment count. If the array is full, allocate an array twice as big as the original. count = 5 size = 10 0 1 2 3 4 5 6 7 8 9 5 10 15 20 30 addEnd(list,40) will result to count = 6 size = 10 0 1 2 3 4 5 6 7 8 9 5 10 15 20 30 40 h) void addFront(List list,int item) - shift all elements to the right so that the item can be placed at position 0, then increment count. Bonus: if the array is full, allocate an array twice as big as the original. count = 5 size = 10 0 1 2 3 4 5 6 7 8 9 5 10 15 20 30 addFront(list,40) will result to count = 6 size = 10 0 1 2 3 4 5 6 7 8 9 40 5 10 15 20 30 i) void removeFront(List list) - shift all elements to the left and decrement count; count = 6 size = 10 0 1 2 3 4 5 6 7 8 9 40 5 10 15 20 30 removeFront(list) will result to count = 5 size = 10 0 1 2 3 4 5 6 7 8 9 5 10 15 20 30 j) void remove(List list,int item) - get the index of the item in the list and then shift all elements to the count = 6 size = 10 0 1 2 3 4 5 6 7 8 9 40 5 10 15 20 30 remove(list,10) will result to count = 5 size = 10 0 1 2 3 4 5 6 7 8 9 40 5 15 20 30

    Read the article

  • Creating C++ client app for some abstract windows server - how to manage TCP connection to server speed?

    - by Kabumbus
    So we have some server with some address port and ip. we are developing that server so we can implement on it what ever we need for help. What are standard/best practices for data transfer speed management between C++ windows client app and server (C++)? My main point is in how to get how much data can be uploaded/downloaded from/to client via his low speed network to my relatively super fast server. (I need it for set up of his live stream Audio/Video bit rate) My try on explaining number 3. We do not care how fast is our server. It is always faster than needed. We care about client tyring to stream out to our server his media. he streams encoded (via ffmpeg) live video data to our server. But he has say ADSL with 500kb/s of outgoing traffic. Also he uses some ICQ or what so ever so he has less than 500 kb/s per second. And he wants to stream live video! So we need to set up our ffmpeg to encode video with respect to the bit rate user can provide. We develop server side and client side. We need a way of finding out how much user can upload per second currently (so value can change dynamically over time)

    Read the article

  • How can I abstract out the core functionality of several Rails applications?

    - by hornairs
    I'd like to develop a number of non-trivial Rails applications which all implement a core set of functionality but each have certain particular customizations, extensions, and aesthetic differences. How can I pull the core functionality (models, controllers, helpers, support classes, tests) common to all these systems out in such a way that updating the core will benefit every application based upon it? I've seen Rails Engines but they seem to be too detached, almost too abstracted to be built upon. I can seem them being useful for adding one component to an existing app, for example bolting on a blog engine to your existing e-commerce site. Since engines seem to be mostly self contained, it seems difficult and inconvenient to override their functionality and views while keeping DRY. I've also considered abstracting the code into a gem, but this seems a little odd. Do I make the gem depend on the Rails gems, and the define models & controllers inside it, and then subclass them in my various applications? Or do I define many modules inside the gem that I include in the different spots inside my various applications? How do I test the gem and then test the set of customizations and overridden functionality on top of it? I'm also concerned with how I'll develop the gem and the Rails apps in tandem, can I vendor a git repository of the gem into the app and push from that so I don't have to build a new gem every iteration? Also, are there private gem hosts/can I set my own gem source up? Also, any general suggestions for this kind of undertaking? Abstraction paradigms to adhere to? Required reading? Comments from the wise who have done this before? Thanks!

    Read the article

  • How to track dealloc of an abstract object class (NSMutable...)

    - by Thomas Tempelmann
    I have a bug in my code caused by a premature freeing of a ObjC object. I seem not to be able to find it by just looking at my code. There's usually a simple trick to track the dealloc to any class: Implement dealloc, and set a breakpoint. This even usually works with standard objects, by subclassing them and making sure I instantiate the subclass instead of the standard class. However, this does not seem to work with NSMutableArray, and probably neither with similar NSMutable... classes. Some explanations for this can be found here: link text Any other ideas how to track the dealloc invocation of a particular class or object so that I can see the call stack? It's probably possible with DTrace. Any pointers without having to read the entire dtrace docs first?

    Read the article

  • What's the deal with all of the abstract stuff?

    - by JustVenting
    I see a lot of talk about MVVM, MVC, Design Patterns etc... You know, some guy has a blog, and he spent the last six months learning about one these things and desiging a program centered around that concept and then he goes on and on about it like its better than sliced bread. I read all of this crap and I wonder, whatever happened to simple logical programming? Not self-absorbed huge frameworks of design patterns and mvc and whatever else you can think of... just simple linear programming, perhaps a few classes to encapsulate things here and there.

    Read the article

  • Any good opensource SharePoint components that can abstract you from the inner SharePoint plumbings?

    - by JL
    I am looking for a good reusable set of components that can be used to communicate with SharePoint via web services, preferably open source. I want some abstraction from CAML and WebDav and SharePoint Web Services that could help me speed up my development time. Ideally I want to select, insert, update and delete from lists, manage attachments in list items, download items from sharepoint, retrieve user meta data from owner info. This sort of thing. Does any such abstraction exist for Sharepoint that use SharePoints web service model, obviously the use of the MOSS Component API is out of the question because it will only run on the hosted MOSS server, and I am writing an SOA app. Thank you

    Read the article

  • How to model and handle presentation DTO's to abstract from complicated domain model?

    - by arrages
    Hi I am developing an application that needs to work with a complex domain model using Hibernate. This application uses Spring MVC and using the domain objects in the presentation layer is very messy so I think I should use DTO's that go to and from my service layer so that these match what I need in my views. Now lets assume I have a CarLease entity whose properties are not simple java primitives but it's composed with other entities like Make, Model, etc public class CarLease { private Make make; Private Model model; . . . } most properties are in this fashion and they are selectable using drop down selects on the jsp view, each will post back an ID to the controller. Now considering some standard use cases: create, edit, display How would you go about modeling the presentation DTO's to be used as form backing objects and communication between presentation and service layers?? Would you create a different DTO for each case (create, edit, display), would you make DTO's for the complex attributes? if so where would you translate the ID to entity? how and where would you handle validation, DTO/Domain assembly, what would you return from service layer methods? (create, edit, get) As you can see, I now I will benefit by separating my view from the domain objects (very complex with lots of stuff I don't need.) but I am having a hard time finding any real world examples and best practices for this. I need some architecture guidance from top to bottom, please keep in mind I will use Spring MVC in case that may leverage on your anwser. thanks in advance.

    Read the article

  • What's the point of indicating AllowMultiple=false on an abstract Attribute class?

    - by tvanfosson
    On a recent question about MVC attributes, someone asked whether using HttpPost and HttpDelete attributes on an action method would result in either request type being allowed or no requests being allowed (since it can't be both a Post and a Delete at the same time). I noticed that ActionMethodSelectorAttribute, from which HttpPostAttribute and HttpDeleteAttribute both derive is decorated with [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] I had expected it to not allow both HttpPost and HttpDelete on the same method because of this, but the compiler doesn't complain. My limited testing tells me that the attribute usage on the base class is simply ignored. AllowMultiple seemingly only disallows two of the same attribute from being applied to a method/class and doesn't seem to consider whether those attributes derive from the same class which is configured to not allow multiples. Moreover, the attribute usage on the base class doesn't even preclude your from changing the attribute usage on a derived class. That being the case, what's the point of even setting the values on the base attribute class? Is it just advisory or am I missing something fundamental in how they work? FYI - it turns out that using both basically precludes that method from ever being considered. The attributes are evaluated independently and one of them will always indicate that the method is not valid for the request since it can't simultaneously be both a Post and a Delete.

    Read the article

  • Implement abstract class as a local class? pros and cons

    - by sinec
    Hi, for some reason I'm thinking on implementing interface within a some function(method) as local class. Consider following: class A{ public: virtual void MethodToOverride() = 0; }; A * GetPtrToAImplementation(){ class B : public A { public: B(){} ~B(){} void MethodToOverride() { //do something } }; return static_cast<A *>(new B()); } int _tmain(int argc, _TCHAR* argv[]) { A * aInst = GetPtrToAImplementation(); aInst->MethodToOverride(); delete aInst; return 0; } the reason why I'm doing this are: I'm lazy to implement class (B) in separate files MethodToOverride just delegates call to other class Class B shouldn't be visible to other users no need to worry about deleting aInst since smart pointers are used in real implementation So my question is if I'm doing this right? Thanks in advance!

    Read the article

  • Hierarchy inheritance

    - by reito
    I had faced the problem. In my C++ hierarchy tree I have two branches for entities of difference nature, but same behavior - same interface. I created such hierarchy trees (first in image below). And now I want to work with Item or Base classes independetly of their nature (first or second). Then I create one abstract branch for this use. My mind build (second in image below). But it not working. Working scheme seems (third in image below). It's bad logic, I think... Do anybody have some ideas about such hierarchy inheritance? How make it more logical? More simple for understanding? Image Sorry for my english - russian internet didn't help:) Update: You ask me to be more explicit, and I will be. In my project (plugins for Adobe Framemaker) I need to work with dialogs and GUI controls. In some places I working with WinAPI controls, and some other places with FDK (internal Framemaker) controls, but I want to work throw same interface. I can't use one base class and inherite others from it, because all needed controls - is a hierarchy tree (not one class). So I have one hierarchy tree for WinAPI controls, one for FDK and one abstract tree to use anyone control. For example, there is an Edit control (WinEdit and FdkEdit realization), a Button control (WinButton and FdkButton realization) and base entity - Control (WinControl and FdkControl realization). For now I can link my classes in realization trees (Win and Fdk) with inheritence between each of them (WinControl is base class for WinButton and WinEdit; FdkControl is base class for FdkButton and FdkEdit). And I can link to abstract classes (Control is base class for WinControl and FdkControl; Edit is base class for WinEdit and FdkEdit; Button is base class for WinButton and FdkButton). But I can't link my abstract tree - compiler swears. In fact I have two hierarchy trees, that I want to inherite from another one. Update: I have done this quest! :) I used the virtual inheritence and get such scheme (http://img12.imageshack.us/img12/7782/99614779.png). Abstract tree has only absolute abstract methods. All inheritence in abstract tree are virtual. Link from realization tree to abstract are virtual. On image shown only one realization tree for simplicity. Thanks for help!

    Read the article

  • ASP.NET MVC 2 RC 2 returns Area-specific controller when no area specified

    - by Bryan
    I have a basic MVC 2 (RC2) site with one base-level controller ("Home"), and one area ("Admin") with one controller ("Abstract"). When i call http://website/Abstract - the Abstract controller in the Admin area gets called even though i haven't specified the Area in the URL. To make matters worse - it doesn't seem to know it's under Admin because it can't find the associated view and just returns: The view 'Index' or its master was not found. The following locations were searched: ~/Views/Abstract/Index.aspx ~/Views/Abstract/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx Am i doing something wrong? Is this a bug? A feature?

    Read the article

  • What's the standard way to organize the contents of Java packages -- specifically the location of in

    - by RenderIn
    I suppose this could go for many OO languages. I'm building my domain objects and am not sure where the best place is for the interfaces & abstract classes. If I have a pets package with various implementations of the APet abstract class: should it live side-by-side with them or in the parent package? How about interfaces? It seems like they almost have to live above the implementations in the parent package, since there could potentially be other subpackages which implement it, while there seems to be a stronger correlation between one abstract class and a subpackage. e.g. com.foo com.foo.IConsumer (interface) com.foo.APet (abstract) com.foo.pets.Dog extends APet implements IConsumer OR com.foo com.foo.IConsumer (interface) com.foo.pets.APet (abstract) com.foo.pets.Dog extends APet implements IConsumer or something else?

    Read the article

  • Persisting non-entity class that extends an entity (jpa) - example?

    - by Michal Minicki
    The JPA tutorial states that one can have a non-entity that extends entity class: Entities may extend both entity and non-entity classes, and non-entity classes may extend entity classes. - http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html Is it possible to persist such structure? I want to do this: @Entity abstract class Test { ... } class FirstConcreteTest extends Test { ... } // Non-ntity class SecondConcreteTest extends Test { ... } // Non-entity Test test = new FirstConcreteTest(); em.persist(test); What I would like it to do is to persist all fields mapped on abstract Test to a common database table for all concrete classes (first and second), leaving all fields of first and second test class unpersisted (these can contain stuff like EJBs, jdbc pools, etc). And a bonus question. Is it possible to persist abstract property too? @Entity abstract class Test { @Column @Access(AccessType.PROPERTY) abstract public String getName(); } class SecondConcreteTest extends Test { public String getName() { return "Second Concrete Test"; } }

    Read the article

  • Postgres cannot connect to server

    - by user1408935
    Super stumped by why Postgres isn't working on a new app I just started. I've got it working for one app already. I'm using postgres.app, and it's running. I started a new app with rails new depot -d postgresql and then I went into the database.yml file and changed username to my $USER (which is what it is for the other app, which is working). So now my database.yml file has this development section: development: adapter: postgresql encoding: unicode database: depot_development pool: 5 username: <username> password: But when I run "rake db:create" or "rake db:create:all" I still got this error (in full, cause I don't know what's relevant): Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"depot_development", "pool"=>5, "username"=>"<username>", "password"=>nil} could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `initialize' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `new' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `connect' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:329:in `initialize' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in `new_connection' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in `checkout_new_connection' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:241:in `block (2 levels) in checkout' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `loop' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `block in checkout' /Users/<username>/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:233:in `checkout' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `block in connection' /Users/<username>/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connection' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in `retrieve_connection' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:144:in `connection' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:107:in `rescue in create_database' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:51:in `create_database' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `block (3 levels) in <top (required)>' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `each' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `block (2 levels) in <top (required)>' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' /Users/<username>/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `load' /Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `<main>' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval' /Users/<username>/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>' Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"depot_test", "pool"=>5, "username"=>"<username>", "password"=>nil} I have tried createdb depot_development I have tried going into the psql environment and listing users (which included my username among them). In the same psql environment, I tried CREATE DATABASE depot; I've made sure that the pg gem is installed with bundle install, I've run "pg_ctl start", to which I got this response: pg_ctl: no database directory specified and environment variable PGDATA unset I ran "ps aux | grep postgres" to make sure postgres was running, to which I got this in return (which looks like it's doing OK, right?): <username> 10390 0.4 0.0 2425480 180 s000 R+ 6:15PM 0:00.00 grep postgres <username> 2907 0.0 0.0 2441604 464 ?? Ss 6:17PM 0:02.31 postgres: stats collector process <username> 2906 0.0 0.0 2445520 1664 ?? Ss 6:17PM 0:02.33 postgres: autovacuum launcher process <username> 2905 0.0 0.0 2445388 600 ?? Ss 6:17PM 0:09.25 postgres: wal writer process <username> 2904 0.0 0.0 2445388 1252 ?? Ss 6:17PM 0:12.08 postgres: writer process <username> 2902 0.0 0.0 2445388 3688 ?? S 6:17PM 0:00.54 /Applications/Postgres.app/Contents/MacOS/bin/postgres -D /Users/<username>/Library/Application Support/Postgres/var -p5432 The short of it, is I've been troubleshooting for a WHILE and have NO idea what's wrong. Any ideas? I'd really appreciate it, cause I'm pretty new to Rails, and this is a pretty disheartening roadblock. Thanks! EDIT -- Per request, posting the successful database.yml . It seems the difference is the inclusion of a password: development: adapter: postgresql encoding: unicode database: *******_development pool: 5 username: ******* password: ******* EDIT2 -- When I add a password to the .yml file, then run rake db:create again, I get this error. rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

    Read the article

  • Storage model for various user setting and attributes in database?

    - by dvd
    I'm currently trying to upgrade a user management system for one web application. This web application is used to provide remote access to various networking equipment for educational purposes. All equipment is assigned to various pods, which users can book for periods of time. The current system is very simple - just 2 user types: administrators and students. All their security and other attributes are mostly hardcoded. I want to change this to something like the following model: user <-- (1..n)profile <--- (1..n) attributes. I.e. user can be assigned several profiles and each profile can have multiple attributes. At runtime all profiles and attributes are merged into single active profile. Some examples of attributes i'm planning to implement: EXPIRATION_DATE - single value, value type: date, specifies when user account will expire; ACCESS_POD - single value, value type: ref to object of Pod class, specifies which pod the user is allowed to book, user profile can have multiple such attributes with different values; TIME_QUOTA - single value, value type: integer, specifies maximum length of time for which student can reserve equipment. CREDIT_CHARGING - multi valued, specifies how much credits will be assigned to user over period of time. (Reservation of devices will cost credits, which will regenerate over time); Security permissions and user preferences can end up as profile or user attributes too: i.e CAN_CREATE_USERS, CAN_POST_NEWS, CAN_EDIT_DEVICES, FONT_SIZE, etc.. This way i could have, for example: students of course A will have profiles STUDENT (with basic attributes) and PROFILE A (wich grants acces to pod A). Students of course B will have profiles: STUDENT, PROFILE B(wich grants to pod B and have increased time quotas). I'm using Spring and Hibernate frameworks for this application and MySQL for database. For this web application i would like to stay within boundaries of these tools. The problem is, that i can't figure out how to best represent all these attributes in database. I also want to create some kind of unified way of retrieveing these attributes and their values. Here is the model i've come up with. Base classes. public abstract class Attribute{ private Long id; Attribute() {} abstract public String getName(); public Long getId() {return id; } void setId(Long id) {this.id = id;} } public abstract class SimpleAttribute extends Attribute{ public abstract Serializable getValue(); abstract void setValue(Serializable s); @Override public boolean equals(Object obj) { ... } @Override public int hashCode() { ... } } Simple attributes can have only one value of any type (including object and enum). Here are more specific attributes: public abstract class IntAttribute extends SimpleAttribute { private Integer value; public Integer getValue() { return value; } void setValue(Integer value) { this.value = value;} void setValue(Serializable s) { setValue((Integer)s); } } public class MaxOrdersAttribute extends IntAttribute { public String getName() { return "Maximum outstanding orders"; } } public final class CreditRateAttribute extends IntAttribute { public String getName() { return "Credit Regeneration Rate"; } } All attributes stored stored using Hibenate variant "table per class hierarchy". Mapping: <class name="ru.mirea.rea.model.abac.Attribute" table="ATTRIBUTES" abstract="true" > <id name="id" column="id"> <generator class="increment" /> </id> <discriminator column="attributeType" type="string"/> <subclass name="ru.mirea.rea.model.abac.SimpleAttribute" abstract="true"> <subclass name="ru.mirea.rea.model.abac.IntAttribute" abstract="true" > <property name="value" column="intVal" type="integer"/> <subclass name="ru.mirea.rea.model.abac.CreditRateAttribute" discriminator-value="CreditRate" /> <subclass name="ru.mirea.rea.model.abac.MaxOrdersAttribute" discriminator-value="MaxOrders" /> </subclass> <subclass name="ru.mirea.rea.model.abac.DateAttribute" abstract="true" > <property name="value" column="dateVal" type="timestamp"/> <subclass name="ru.mirea.rea.model.abac.ExpirationDateAttribute" discriminator-value="ExpirationDate" /> </subclass> <subclass name="ru.mirea.rea.model.abac.PodAttribute" abstract="true" > <many-to-one name="value" column="podVal" class="ru.mirea.rea.model.pods.Pod"/> <subclass name="ru.mirea.rea.model.abac.PodAccessAttribute" discriminator-value="PodAccess" lazy="false"/> </subclass> <subclass name="ru.mirea.rea.model.abac.SecurityPermissionAttribute" discriminator-value="SecurityPermission" lazy="false"> <property name="value" column="spVal" type="ru.mirea.rea.db.hibernate.customTypes.SecurityPermissionType"/> </subclass> </subclass> </class> SecurityPermissionAttribute uses enumeration of various permissions as it's value. Several types of attributes imlement GrantedAuthority interface and can be used with Spring Security for authentication and authorization. Attributes can be created like this: public final class AttributeManager { public <T extends SimpleAttribute> T createSimpleAttribute(Class<T> c, Serializable value) { Session session = HibernateUtil.getCurrentSession(); T att = null; ... att = c.newInstance(); att.setValue(value); session.save(att); session.flush(); ... return att; } public <T extends SimpleAttribute> List<T> findSimpleAttributes(Class<T> c) { List<T> result = new ArrayList<T>(); Session session = HibernateUtil.getCurrentSession(); List<T> temp = session.createCriteria(c).list(); result.addAll(temp); return result; } } And retrieved through User Profiles to which they are assigned. I do not expect that there would be very large amount of rows in the ATTRIBUTES table, but are there any serious drawbacks of such design?

    Read the article

  • Updating textfield in doctrine produces an exception

    - by james-murphy
    I have a textfield that contains say for example the following text:- "A traditional English dish comprising sausages in Yorkshire pudding batter, usually served with vegetables and gravy." This textfield is in a form that simply updates an item record using it's ID. If I edit part of the textfield and replace "and gravy." with "humous." So that the textfield now contains "A traditional English dish comprising sausages in Yorkshire pudding batter, usually served with vegetables and humous." I get the following exception:- Fatal error: Uncaught exception 'Doctrine_Query_Exception' with message 'Unknown component alias humous' in C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php:780 Stack trace: C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(767): Doctrine_Query_Abstract-getQueryComponent('humous') C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Set.php(58): Doctrine_Query_Abstract-getAliasDeclaration('humous') C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(2092): Doctrine_Query_Set-parse('i.details = 'A ...') C:\Projects\nitrous\lightweight\system\database\Doctrine\Query.php(1058): Doctrine_Query_Abstract-_processDqlQueryPart('set', Array) C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(971): Doctrine_Query-getSqlQuery(Array) C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php(1030): Doctrine_Query_Abstract-_execute(Array) C:\Projects\nitrous\lightweight\system\appl in C:\Projects\nitrous\lightweight\system\database\Doctrine\Query\Abstract.php on line 780 I'm using Doctrine 1.0.6 hooked into CodeIgniter 1.7.0 if anyone is interested. My doctrine query that actually performs the update looks as follows:- public function updateItems($id, $arrayItem) { $query = new Doctrine_Query(); $query->update('Item i'); foreach($arrayItem as $key => $value) { $query->set('i.'.$key, "'".$value."'"); } $query->where('i.id = ?', $id); return $query->execute(); } This seems bizarre because if i replace the entire string "A traditional English dish comprising sausages in Yorkshire pudding batter, usually served with vegetables and humous." with something completely different like just "test" it doesn't throw an exception and works just fine. This baffles me... is it a bug in Doctrine or have I missed something?

    Read the article

  • multiple-inheritance substitution

    - by Luigi
    I want to write a module (framework specific), that would wrap and extend Facebook PHP-sdk (https://github.com/facebook/php-sdk/). My problem is - how to organize classes, in a nice way. So getting into details - Facebook PHP-sdk consists of two classes: BaseFacebook - abstract class with all the stuff sdk does Facebook - extends BaseFacebook, and implements parent abstract persistance-related methods with default session usage Now I have some functionality to add: Facebook class substitution, integrated with framework session class shorthand methods, that run api calls, I use mostly (through BaseFacebook::api()), authorization methods, so i don't have to rewrite this logic every time, configuration, sucked up from framework classes, insted of passed as params caching, integrated with framework cache module I know something has gone very wrong, because I have too much inheritance that doesn't look very normal.Wrapping everything in one "complex extension" class also seems too much. I think I should have few working togheter classes - but i get into problems like: if cache class doesn't really extend and override BaseFacebook::api() method - shorthand and authentication classes won't be able to use the caching. Maybe some kind of a pattern would be right in here? How would you organize these classes and their dependencies? EDIT 04.07.2012 Bits of code, related to the topic: This is how the base class of Facebook PHP-sdk: abstract class BaseFacebook { // ... some methods public function api(/* polymorphic */) { // ... method, that makes api calls } public function getUser() { // ... tries to get user id from session } // ... other methods abstract protected function setPersistentData($key, $value); abstract protected function getPersistentData($key, $default = false); // ... few more abstract methods } Normaly Facebook class extends it, and impelements those abstract methods. I replaced it with my substitude - Facebook_Session class: class Facebook_Session extends BaseFacebook { protected function setPersistentData($key, $value) { // ... method body } protected function getPersistentData($key, $default = false) { // ... method body } // ... implementation of other abstract functions from BaseFacebook } Ok, then I extend this more with shorthand methods and configuration variables: class Facebook_Custom extends Facebook_Session { public funtion __construct() { // ... call parent's constructor with parameters from framework config } public function api_batch() { // ... a wrapper for parent's api() method return $this->api('/?batch=' . json_encode($calls), 'POST'); } public function redirect_to_auth_dialog() { // method body } // ... more methods like this, for common queries / authorization } I'm not sure, if this isn't too much for a single class ( authorization / shorthand methods / configuration). Then there comes another extending layer - cache: class Facebook_Cache extends Facebook_Custom { public function api() { $cache_file_identifier = $this->getUser(); if(/* cache_file_identifier is not null and found a valid file with cached query result */) { // return the result } else { try { // call Facebook_Custom::api, cache and return the result } catch(FacebookApiException $e) { // if Access Token is expired force refreshing it parent::redirect_to_auth_dialog(); } } } // .. some other stuff related to caching } Now this pretty much works. New instance of Facebook_Cache gives me all the functionality. Shorthand methods from Facebook_Custom use caching, because Facebook_Cache overwrited api() method. But here is what is bothering me: I think it's too much inheritance. It's all very tight coupled - like look how i had to specify 'Facebook_Custom::api' instead of 'parent:api', to avoid api() method loop on Facebook_Cache class extending. Overall mess and ugliness. So again, this works but I'm just asking about patterns / ways of doing this in a cleaner and smarter way.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >