metaclass: (Default)
[personal profile] metaclass
А поимею-ка я вам мозг классической задачкой из любой опердени.
Дано: в базе данных есть таблица фактов (проводки, платежи, вообще любые первичные операции). В таблице обычно имеется дата-время операции, сумма, и куча полей с аналитическими кодами (от кого, кому, дебет-кредит, тип операции, итд).

И есть набор правил, согласно которым эта таблица раскладывается по статьям некоего выходного отчета который ложится на стол Президенту РБ, т.е. к примеру "все проводки с типом операции 126 относятся на статью затрат "Цех забоя и переработки свинины", за исключением проводок со счета 91, который относится на статью затрат "Цех забоя и переработки лошадей"". В таких правилах обычно проверяется где-то 5-10 условий на значения полей записи операции, самих правил может быть порядка сотни штук. И правила могут меняться, например в 2008 году переработка лошадей и свиней делилась на две статьи, а в 2009 министерство статистики решило, что достаточно одной статьи "забой любого скота", но обязательно детализированной по фазам луны.

И вот как бы вы такое решали?

Анализ этого дела в коде выглядит как паттерн-матчинг, реализованный вручную. Но в код это пихать как бэ нехорошо - потому что при изменениях правил придется менять код. А если хранить правила в таблице, получается что мы впадаем в грех реализации собственного языка правил и его обработки.

PS: Здесь немного объяснено, что имеется в виду под "грехом собственного языка".

Date: 2009-11-18 04:17 pm (UTC)
From: (Anonymous)
SQL is not really suitable as a business rules language. People are inventing Prolog clones like DRools, and those are smart people, like from IBM Labs et al. They cross unification construct of logical programming with functional approach and practical library. Also they made lot of infrastructure -- GUI, unit testing, versions/namespaces/baseline, inter-language interface etc.

SQL is a smart hack but not maintainable at all for a big ruleset.
I'd suggest using SQL for getting the result of classification (SQL is an output of the reporting, not a processing engine.) And PL/SQL (T-SQL) is even worse than SQL. Real maintainance nightmare.

OTOH metaclass should have been started from reporting tools, not from classification phase. It all depends on the requirements of course (I just wonder if he knows about MDX for example).

Date: 2009-11-18 04:30 pm (UTC)
From: [identity profile] mudasobwa.livejournal.com
I have just answered the question, I had no purpose to teach or to share a knowledge.

As far as I understood the problem, MDX is overkill for it. We have an amount of fields and some restrictions (to say, queries) applied on resultsets. There is no multidimensional data at all and using such tools as DRolls will dramatically slow the development down.

And, increase the cost, as far.

Date: 2009-11-18 05:19 pm (UTC)
From: [identity profile] metaclass.livejournal.com
Reporting tools used in our current projects support only SQL query results. So if I will be implementing this report with current tools then it will be ruleset in table (one record - rule+time span of rule activity) and selectable stored procedure for report generation. Stored procedure and rule table may be autogenerated to avoid manual coding of facts table processing.

Date: 2009-11-18 07:00 pm (UTC)
From: (Anonymous)
Наверное, можно было и по-русски. У человека, может, просто клавиатуры русифицированной под рукой нет. :)

Date: 2009-11-18 07:07 pm (UTC)
From: [identity profile] metaclass.livejournal.com
А, а я думал, это так модно :)

Date: 2009-11-19 12:50 am (UTC)
From: [identity profile] theiced.livejournal.com
а нахрена она нужна? если ойтишник не умеет тайпать вслепую - то он даун и его мнение в хуй не впилось.

Date: 2009-11-19 02:52 pm (UTC)
From: (Anonymous)
Do you ever realized that the same question "а нахрена она нужна?" can be told about occasionally using Russian when not having it ready?
Especially when talking to an aggressive gay one (like you).

Konechno mogu pisat translitom i dasche hodit na translit.ru. A bit too much for a small comment.

Profile

metaclass: (Default)
metaclass

April 2017

S M T W T F S
      1
2345678
9101112 131415
16171819202122
23242526272829
30      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 22nd, 2025 07:48 am
Powered by Dreamwidth Studios